Tag Archives: puzzles

How to fix “property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects”

Today Xcode surprised me with an error message I hadn’t heard before: property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects.

At first I thought, “isn’t that a good thing?”, and after checking how I had defined a new property I was clueless why this was happening:

What I had done was define a new property that starts with “new”. Doing so means that Xcode / ARC does not automatically create the getter/setter methods for me automatically, and expects me to do it (since I own the object outright). Not having done so throws an error message at build time.

To avoid this problem, don’t start properties beginning with

  • new
  • alloc
  • copy
  • mutableCopy

If you must name properties with those prefixes, then you need to create everything Xcode would do for you too. Most of us really don’t know/care what that is so it’s probably easier to just change that property.

You can use things like “new” for objects you create during the course of your methods, just not as properties. The following works just fine:

Managed Object Context arrives empty when passed via a segue in iOS 5

I’ve just found that passing an NSManagedObjectContext object via a segue in iOS 5 doesn’t work: the property remains empty.

In iOS 6 on the other hand this isn’t a problem: the context arrives just like any other property would, and as logic would dictate. Here’s code from an amended Utility Template app:

Trying to execute a Fetch Request on FlipsideViewController results in this error message:

+entityForName: could not locate an NSManagedObjectModel for entity name ‘YourEntity’

The fact that this is fixed (yet completely undocumented) means that Apple knew about this and made it work in iOS 6. Why this doesn’t work in iOS 5 is anyone’s guess.

I’m trying to read out the value of a UISlider and put it into a UIProgressView. Not a problem, all I need is to divide my UISlider.value by 100 to get the correct output. So far so good.

However, for some reason this statement does not work. I don’t know why:

Doesn’t make sense. All I’m doing is dividing the self.mySlider.value by 100, giving me the value that I need. If I do it by passing this value into a variable which I divide by 100 it works perfectly fine: