Reputation: 1221
I'm trying to store data with Realm in iOS but I'm facing the problem it does not stored data. I found similar question but I'm not sure how to get existing database.
Why is my Realm object not saving stored values?
Here is my code.
@interface database : RLMObject
@property NSString *name;
@property NSString *age;
@end
@implementation database
@end
RLM_ARRAY_TYPE(database)
In Appdelegate.m
database *db = [[database alloc] init];
db.name = @"David Test";
db.age = @"30";
[realm beginWriteTransaction];
[realm addObject:db];
[realm commitWriteTransaction];
Then I get allObjects like below
RLMResults *result = [database allObjects];
Shutting down app once,RLMResults has no data.
Does anyone have any idea?
Thanks in advance!
Upvotes: 0
Views: 650
Reputation: 14409
Is it possible the realm
variable you're using is initialized with +[RLMRealm realmWithPath:]
? The [database allObjects]
call will only query the default realm (created with [RLMRealm defaultRealm]
).
Although it's impossible to say with any certainty what exactly is happening without more information.
Upvotes: 1
Reputation: 65
I use FMDB, you could search it through here.https://github.com/realm/realm-cocoa ,github. good luck
Upvotes: 0