简体   繁体   中英

Tree hierarchy data [users => session => results]

Still new to xcode, please excuse any errors or misunderstanding, i hope being the clearest possible

I have a user list containing some usernames (user1, user2, user3...). I saved this list in a NSMutableArray that i get by NSUserDefaults.

Now, in my app, each user is going to create his own one or several sessions. And each session will save one or several results.

I can't post any image so this is a simple way to represent what i want :

  user1 

session 1 session 2

result1 (session1) // result1 (session2)

result2(session1) // result2(session2)

result3 (session1)

I tried to find out some methods or something like that but maybe my key words are not enough pertinent. What will be the best solution to do that ?

I was thinking using a NSMutableArray saving all the session for each user in a NSUserDefaults with objectForKey the name of the user (and the same thing for the results except setting objectForkey the name of the session) but i think it is gonna be very tough and long...

Thank you guys !!!!

For any sort of complex data with relationships you should move on to using CoreData. NSUserDefaults really excels when having simple key-value pairs, but nothing more.

It's a bit of a learning curve to get into it, but once it's set up, you'll understand why it's better to go this way.

CoreData Programming Guide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM