开发者

database on iphone

friend i want that , i have xib and that xib name is mapper ok and this xib i have one tab bar button a开发者_StackOverflownd in this tabbar i give link of web server page which direct open the user registration from and user can fill there from easy ok on the registration from have submit button if user submit there data then after i have fast retrive there data from server database which user fill on registration from and that i have get username and password bec after the registration from complete then user come on login pagexib in this xib i have give a

authority to user please enter ur username and password if user enter there username and password he should chek from database it this username have or not and this all information i have to store from server to local database after this hapen then i have to match username and password from local database which i am sqlitedatabase it this possbel friend if yes then give me some information about yhis type of database save and retrive in iphone and please give me some small code of this releted this project


Check out the NSUserDefaults object in the apple docs http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html

It's as simple as this

-(void)saveCustomObject:(MyCustomObject*)obj
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:obj];


    [defaults setObject:myEncodedObject forKey:@"myEncodedObjectKey"];
}

-(MyCustomObject*)loadCustomObjectWithKey:(NSString*)key
{
    NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];
    NSData *myEncodedObject = [defaults objectForKey: key];
    MyCustomObject* obj = (MyCustomObject*)[NSKeyedUnarchiver unarchiveObjectWithData: myEncodedObject];
    return obj;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜