In iOS development, is it possible to use NSString and return it from a function?
e.g.
(NSString * ) foo {
return @"";
}
This is not an objective c method, just function
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, seeing as objective-c objects are just pointers, you can create a C function to return one:
Notice the use of
NS_RETURNS_RETAINED. This is a hint to ARC and the static analyzer that this function returns a retained value to the receiver, and that it’s their responsibility to release it.If you were returning an autoreleased value, try using
NS_RETURNS_NOT_RETAINEDinstead.