2013-08-18 41 views
0

我工作的一個應用程序,允許用戶在多個login.Logged用戶可以在本地存儲的某些細節,他必須我沒有使用核心數據的登錄部分查看這些細節他下次登錄。 。但我上存儲和讀取特定user.Please的detais幫助我還是建議我同一個很好的教程完全一無所知。存儲和獲取用戶的詳細信息

回答

0

您可以閱讀或this tutorialother。 我跟你說話,你必須做什麼: 你需要在你appDataModel.momd文件創建一個實體「用戶」(例如)。對於「用戶」,您可以添加以後需要使用的屬性(例如:名稱,ID,年齡等)。現在,你必須創建實體類User.h和User.m(看教程),進口User.h上課,在那裏你會在一些方法創建讀取請求和創建(獲取請求)(在教程看)。 要建立實體的範例: (User_John例如)

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
NSManagedObjectContext *context = appDelegate.managedObjectContext; 
NSEntityDescription *entity = [NSEntityDescription entityForName:@"User" inManagedObjectContext:context]; 

User *User_John = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; //create variable of new user 
[email protected]"John"; 
User_John.age=23; 
User_John.id=1; 

您需要更改用戶參數只使用setter方法:

User_John.age=24; 

OR:

[User_John setValue:24 forKey:@"age"];