i randomly found a tutorial in the xcode documentation to do with core data
it involves employees and departments
In the part where it creates the employee and gives it a unique id i'm rather confused as to how this was achieved...
the value of the popupbox comes from the returned string from -(NSString*)fullNameAndID
which is derived from lastName, firstName, and employeeID
lastName and firstName are declared a @property (retain) in the header file (what does that mean?) as NSStrings, and employee is the same but as an NSNumber
so when the program runs the popup box gives the lastName firstName + employeeID
but to make the employeeID unique this code was inserted
and primitiveEmployeeID was added to the header file as @property (retain) NSNumber
and when the program runs the employeeID is now unique...
how is that possible? employeeID is never touched... yet it gets incremented each time a new employee entity is added to the array controller
also, the tutorial says that this is not a great way of doing this.... what should the correct way of making sure an entity's property value is unique?
it involves employees and departments
In the part where it creates the employee and gives it a unique id i'm rather confused as to how this was achieved...
the value of the popupbox comes from the returned string from -(NSString*)fullNameAndID
which is derived from lastName, firstName, and employeeID
lastName and firstName are declared a @property (retain) in the header file (what does that mean?) as NSStrings, and employee is the same but as an NSNumber
so when the program runs the popup box gives the lastName firstName + employeeID
but to make the employeeID unique this code was inserted
Code:
- (void)awakeFromInsert {
static NSInteger tempID = 1;
[super awakeFromInsert];
self.primitiveEmployeeID = [NSNumber numberWithInteger:tempID++];
}
and when the program runs the employeeID is now unique...
how is that possible? employeeID is never touched... yet it gets incremented each time a new employee entity is added to the array controller
also, the tutorial says that this is not a great way of doing this.... what should the correct way of making sure an entity's property value is unique?