- (void)webViewDidFinishLoad:(UIWebView *)webView {
if (urlIndex == maxIndex) {
maxIndex = maxIndex + 1;
NSString* sURL = webpage.request.URL.absoluteString;
[urlHistory addObject:sURL];
NSLog(@"%d: %@", urlIndex, [urlHistory objectAtIndex:urlIndex]);
NSLog(@"%d: %@", urlIndex, webpage.request.URL.absoluteString);
[sURL release];
urlIndex = urlIndex + 1;
}
else {
[urlHistory insertObject:webView.request.URL.absoluteString atIndex:(urlIndex - 1)];
}
}
此行式IO /目标C:添加的NSString对象的NSMutableArray,NSMutableArray的是(空)
NSLog(@"%d: %@", urlIndex, [urlHistory objectAtIndex:urlIndex]);
打印(无效),而作为该行
NSLog(@"%d: %@", urlIndex, webpage.request.URL.absoluteString);
打印该实际的网址。
在我initWithNibName我:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:@"Tab1ViewController" bundle:nil];
if (self) {
urlHistory = [[NSMutableArray alloc] init];
urlIndex = 0;
maxIndex = 0;
}
return self;
}
但我仍然不断收到(空),当我进入我的数组。这是为什么?
是你的问题中的拼写错误,你正在添加对象到urlIndex(大概是一个整数)而不是urlHistory? – jrturton
是的,修正了那个谢谢,但那是在一个不相关的线上... – Gibson
有没有不相关的线:) – jrturton