Friday, August 1, 2014

iphone: core data(database) storage

In constant.m
NSString *const kEntityNameUser = @"User";
In constant.h
extern NSString *const kEntityNameUser;


In manager file



- (void)createNewUser :(NSString *)username
                      :(NSString *)password
                      
{
    
    User *newUser = [NSEntityDescription insertNewObjectForEntityForName:kEntityNameUser inManagedObjectContext:self.context];
  
       newUser.username=username;
    newUser.password=password;
    
    [self save];

}



-(void)save {
    NSError *error;
    [self.context save:&error];
}



No comments:

Post a Comment