質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top