2
votes

Ok, I have read a lot of posts and resources about this but I am STILL having the same issue. I have a few NSString variables that I need to be class-wide variables used in multiple places throughout the class. I have tried many combinations of settings. First of all, I do have the strings declared in the interface like so:

@interface iCodeViewController : UIViewController <NSXMLParserDelegate> {

    NSString *myString;
}

I have also added the property as follows (I have tried with and without the property and synthesizing)

@property (readwrite, retain) NSString *myString;

I have also tried, (nonatomic, retain), (nonatomic, copy), (readwrite, copy).

Then in the .m file:

@synthesize myString;

I have tried:

self.myString = @"whatever";
myString = @"whatever";

I have also tried with and without allocating memory to it by:

myString = [[NSString alloc] init];

What am I missing??

After I have 'supposedly' set the string variable in one method, I try to check it in another with if ([myString isEqualToString:@"blah blah"]) and when I put in a breakpoint and hover over myString it is always showing 'invalid summary.

Thanks!

3

3 Answers

1
votes

use below

@property (nonatomic, retain) NSString *myString;
self.myString = [NSString  stringWithString:@"whatever"];

for more read the SO post

Invalid Summary in NSString assignment

0
votes

Can you place the class code here? The way you are handling your myString is perfectly fine. One possibility I can think of is that you are forgetting to return self from the init method.

There could be other possible memory related mess some where in your code.

0
votes

I was able to reproduce the invalid summary by initializing an NSMutableString to size 100 and only appending to it. I found the problem went away when I called

[mutableString setString:@""];

prior to

[mutableString appendString:string];