سؤال

A. Is it possible/appropriate to initialize NSXML parse for a selected row inside didSelectRowAtIndexPath in order to populate the detail view that the method pushes to? I want to parse the URL associated with the title of a selected item as a detailview...

B. If yes, then how can I make it happen? I have 'afeed.title' In the following critter:

NSXMLParser *urlParser = [[NSXMLParser alloc] initWithContentsOfURL:afeed.url];

A caution line exclaims at afeed.url: "Incompatible pointer types sending 'NSString *' to parameter of type 'NSURL *'"

afeed is create by this:

ArticleGroupLink *afeed = [array objectAtIndex:indexPath.row];

ArticleGroupLink is a class containing title (title was used in the cellForRowAtIndexpath method) & url (string & @ property), which synthesizes them.

Let me know anything else that I need to share : )

هل كانت مفيدة؟

المحلول

As the compiler is trying to tell you is that it's expecting a NSURL object but instead you are giving it a NSString object.

So you can try to convert your NSString into a NSURL by doing something like this:

NSString *urlString = afeed.url;
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

Then you can do:

NSXMLParser *urlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top