I have created a simple class called Engine which has an ivar called inputName ( NSMutableString ). Properties have been set ocordingly and all works fine. When I create and instance of Engine called car and set inputName I get the following warning:
Assigning retained object to unsafe property, object will be released after assignment.
Apart from the message, car.inputName has been allocated memory and initialized correctly.
When declaring properties (@property NSMutableString *inputName;) I did not assign any attributes. But if I add (strong) I do not get the above warning. How can this be when strong is the default attribute ?? and what would be the best way to give car.inputName a string.
#import "Engine.h"
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
Engine *car = [[Engine alloc]init];
car.inputName = [[NSMutableString alloc]initWithString:@"Ford Escot"];
// yellow warning:Assigning retained object to unsafe property, object will be released after assignment
}
return 0;
}
strongis not the default.assignis the default.