Reputation: 21005
which of the following namings is more 'right'?
- (void) forPrimaryKeySetValue:(id)value
or
- (void) setValueForPrimaryKey:(id)value
what it does : its a NSManagedObject category method, which searches the userInfo of the entity for a key primaryKey and if it is pressend, than sets the value of the corresponding(primaryKey) attribute to value
Upvotes: 0
Views: 95
Reputation: 119292
What does the method do? The second is the default setter name for an ivar called valueForPrimaryKey
. If all you're doing is setting a primary key, the method should probably be called setPrimaryKey:
- the valueFor is superfluous.
I don't fully follow your explanation of what the method does, but I guess you're setting it up so that you can call this method on any managed object, and it will set the primary key value if it exists, otherwise it will fail safely? In that case, something like safeSetPrimaryKey:
? I'm not sure of a convention for this type of method, but you shouldn't stray too far from the standard if it's just a glorified setter, and the value stuff is still confusing.
Upvotes: 2