cocoa - NSArrayController initialization -
I have a problem getting the NSARAC controller for core-data backup to work properly in my code My code is:
pageorder controller = [[NSArrayController alloc] initWithContent: zero]; [PageArrayController Set ManagedObjectContext: [Self-Managed ObjectCurrent]]; [PageArrentRularSetTNName: @ "page"]; [PageRerentler SetAvides Blank Selection: Yes]; [PageArrayControllerSetting SelectionSeek: Yes]; [Page array controller set related objects: Yes]; [PageArrayController set ClearsFilterPredicateOn representation: Yes]; [PageRarenterSet disabled: Yes]; [PageArray Controller SetupCopyrage Content: Yes]; [PageArrayControllerSetDescriptors: [NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey: @ "Index" ascending: Yes]]]; BOOL Result = [Select PageArrentRularSidex: 0];
When I try to call setSelectionIndex, it returns YES, indicating that the selection has been changed successfully. However, the PageErrorController calls the object to any later session index returns returns to NSNotFound.
What I do not understand is that if I put NISRAC controller in NIB, and allows NIB to initialize the file (all with the same feature in the interface builder), NSArrayController is correct Works the way.
Why is the difference in behavior? Does NIB file start these types of items in a special way? Is my NSArrayController wrong?
Any help is appreciated. Thank you.
Yes, nibs start objects in a special way and sometimes it can be difficult to find out How to replicate that I also struggled with it and finally got the answer in Apple's Core Data Programming Guide >> Core Data and Coca Bindings >> (thanks to Dave Fernandes in the list). The answer is that if you initialize an array controller with zero content, then you have to do a fetch as well.
bool results; NSArrayController * pageArrayController = [[NSArrayController alloc] initWithContent: zero]; [PageArrayController Set ManagedObjectContext: [Self-Managed ObjectCurrent]]; [PageArrentRularSetTNName: @ "page"]; NSError * error; If ([PageArrnroller Fetch Destest: Zero Merging: Yes Error: & amp; Error] == No) Results = No; Else {// Everything else pageArch Controller Configuration Content Results = [pageArerentRollerConceptSecondxX: 0]; }
BTW, [nsort descriptor sort descriptor with: @ "index" ascending: yes]] raises a warning.
Comments
Post a Comment