简体   繁体   English

NSString“无效摘要”

[英]NSString “invalid summary”

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.我有一些 NSString 变量,我需要在整个 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:然后在.m文件中:

@synthesize myString;

I have tried:我努力了:

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

I have also tried with and without allocating memory to it by:我还尝试通过以下方式分配和不分配 memory 给它:

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.在我“假设”在一种方法中设置字符串变量后,我尝试使用if ([myString isEqualToString:@"blah blah"])在另一个方法中检查它,当我在 myString 上放置断点和 hover 时,它总是显示'无效的总结。

Thanks!谢谢!

use below在下面使用

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

for more read the SO post有关更多信息,请阅读 SO 帖子

Invalid Summary in NSString assignment NSString 分配中的摘要无效

Can you place the class code here?你能把 class 代码放在这里吗? The way you are handling your myString is perfectly fine.您处理 myString 的方式非常好。 One possibility I can think of is that you are forgetting to return self from the init method.我能想到的一种可能性是您忘记从 init 方法返回 self 。

There could be other possible memory related mess some where in your code.在您的代码中的某些地方可能还有其他可能的 memory 相关混乱。

I was able to reproduce the invalid summary by initializing an NSMutableString to size 100 and only appending to it.我能够通过将 NSMutableString 初始化为大小 100 并仅附加到它来重现无效摘要。 I found the problem went away when I called我打电话时发现问题消失了

[mutableString setString:@""];

prior to之前

[mutableString appendString:string]; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM