Efficiently implementing simple NSComboBox functionality with bindings


i made sample core data application, in populated nscombobox name of student entity, binding content values property array controller. wanted add new record persistent store if student name not exist, defined method in application delegate class:

code:
- (ibaction)addnewstudent:(id)sender     {         nsarray *studentnames = [[students arrangedobjects] valueforkey:@"name"];         if ([studentnames containsobject:[sender stringvalue]]) {             return;         }                  nsmanagedobjectcontext *context = [self managedobjectcontext];         nsentitydescription *studententity = [nsentitydescription entityforname:@"student" inmanagedobjectcontext:context];                   // inserting record         nsmanagedobject *newrecord = [nsentitydescription insertnewobjectforentityforname:[studententity name] inmanagedobjectcontext:context];         [newrecord setvalue:[sender stringvalue] forkey:@"name"];                  nserror *error = nil;         if (![context save:&error]) {             nslog(@"unresolved error %@, %@",error,[error userinfo]);             abort();         }     }
can suggest me, if best way implement or there other better approach implement it?
 



Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Has to be the funniest headline ive ever seen

Man Brings Goat to Apple Store and has Pizza Delivered

Elusive Ninja: The Shadowy Thief - Can you survive the fast-paced ninja chaos?