开发者

Why is my NSMutableSet empty?

I have an object that has just one member with a property of type NSMutableSet called URLs. I have a view controller that is performing this loop:

NSString *link = [NSString stringWithFormat:@"document.links[%d].toString()", i];
NSString *links = [self.webView stringByEvaluatingJavaScriptFromString: link];
NSURL *URL = [[NSURL alloc] initWithString:links];
NSString *lastPath = [URL lastPathComponent];

if ( [lastPath hasPrefix:comparisonString] ) {

[model.URLs addObject:links];

}

NSLog(@"Count: %d", [model.URLs count]);

But the log function prints 0 for me, and I'm positive I have a few cases where the if statement is true because I log that as well and see it fire a few times. An开发者_开发百科y pointers?


Are you sure that model.URLs points to a valid NSMutableSet? If it's nil, you'll still get 0 for the count in the log statement, and the -addObject: call will just do nothing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜