Frage

If I put an NSURL in a class declaration and set it to something in a method, when the method finishes the object it's pointing to is gone. Is there a way to have a non pointer version of an object in the declaration like you can in C++? XCode doesn't seem to want to let me.

War es hilfreich?

Lösung

Is there a way to have a non pointer version of an object in the declaration like you can in C++? XCode doesn't seem to want to let me.

NSObject types don't support this. Even creating your own root objc class is not supported with Clang (you could do it with GCC if you were geeky enough). Thus, the short answer is "No, you can't declare a NSObject type by value".

But that's not really important; the right solution is to figure out why your member is cleared -- using ref counted pointers works for everybody else.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top