NSString *newData = @"%@", newDataField;
NSString *newData = [NSString stringWithFormat:@"%@",[newDataField stringValue]];
- (void)setInfo:(NSString *)newInfo {
if (info != newInfo) {
[info release];
info = [newInfo copy];
}
}
- (void)setInfo:(NSString *)newInfo {
// If values are the same, do nothing.
// Use isEqualToString, not ==, as you should care about the strings'
// values, not whether they are the same object.
if ([info isEqualToString:newInfo]) {
return;
}
// If info is not nil, release it.
if (info != nil)
[info release];
// Now assign the value to info, and be sure to retain it
// or else it will get autoreleased.
info = [[newInfo copy] retain];
}
What does "error: statically allocated instance of Objective-C class 'NSString'" mean?
Also, what does "warning local declaration of 'newData' hides instance variable" mean?
please tell how to fix this warning
The error occurs after this line
NSString *newData = @"%@", newDataField;
The warning occurs after this line
[self setInfo: newData];
Code:- (void)setInfo:(NSString *)newInfo { if (info != newInfo) { [info release]; info = [newInfo copy]; } }
I don't know if this is the entire problem, but this section seems off.
Code:if (info != nil) // this check isn't really necessary -- [nil release] is a perfectly valid no-op [info release]; // releasing once info = [[newInfo copy] retain]; // retaining twice