Referencing a string inside an NSURL

2019-08-23 12:37发布

问题:

I'm trying to use this string inside this NSURL however I don't think its right and in turn giving me an ASI HTTP request failed error.

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://furious-ice-356.heroku.com/places/%@/reviews.xml",self.identifier]];

回答1:

self.identifier returns (in most cases) an object of the type id. You cannot cast this object to a NSString*.

The only exception is the in 10.7 newly introduced identifier property of NSString* in the NSUserInterfaceItemIdentification protocol.

Can you elaborate your question so we can see what type self has?