Эй, ребята, у меня возникли некоторые проблемы при добавлении NSURL в массив и их циклическом просмотре. Вот соответствующие части моего кода:
RSS_ReaderAppDelegate.h:
@interface RSS_ReaderAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *navigationController;
NSDictionary *RSSFeeds;
NSMutableArray *RSSFeedURLs;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) NSDictionary *RSSFeeds;
@property (nonatomic, retain) NSMutableArray *RSSFeedURLs;
RSS_ReaderAppDelegate.m:
@implementation RSS_ReaderAppDelegate
@synthesize window;
@synthesize navigationController;
@synthesize RSSFeeds, RSSFeedURLs;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSURL *url1 = [[NSURL alloc] initWithString:@"http://<some url>"]; //real URL has been hidden
NSURL *url2 = [[NSURL alloc] initWithString:@"http://<some other url>"]; //real URL has been hidden
[RSSFeedURLs initWithObjects: url1, url2, nil];
[url1 release];
[url2 release];
for (NSURL *url in RSSFeedURLs) { //jumps right over this for loop
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
XMLParser *parser = [[XMLParser alloc] init];
[xmlParser setDelegate:parser];
//Start parsing the XML file.
BOOL success = [xmlParser parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error(s) encountered");
}//for
// Add the navigation controller's view to the window and display.
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
Так что [RSSFeedURLs initWithObjects: url1, url2, nil];
, похоже, на самом деле ничего не делает, так как когда я запускаю отладчик и набираю "po RSSFeedsURLs", он сообщает: "Невозможно получить доступ к памяти по адресу 0x0", и поэтому цикл for никогда не вводится. Я понятия не имею, почему это так, может кто-нибудь пролить свет на эту ситуацию для меня? Заранее спасибо.