arrayController.arrangedObjects[index].title = newValue;
Using Core Data in code - Objective-C/Cocoa
-
02-04-2022 - |
문제
I have Core Data entity named Event
in my xcdatamodeld
with 2 attributes : title
and date
. I have also an arrayController
set to Entity mode with the Event
entity (done with interface builder). I want to access the attributes of the objects in the arrayController
using code. How can I do that?
해결책 2
다른 팁
I agree with the other posters about looking into some of the docs on core data. The Big Nerd Ranch books are a really great starting point if you find the online documentation overwhelming (it comes in time).
Select your Event
entity in your xcdatamodel
, then from the menu do:
Editor > Create NSManaagedObject Subclass
Then you can do:
Event *event = [arrayController.arrangedObjects[index]];
event.title = newValue or [event setTitle];
I suggest starting with the Apple tutorial, Core Data Tutorial for iPhone OS, then moving on to one of the sample apps, such as CoreDataBooks. Core Data is not an easy technology to master, so expect this to take some time.