Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Chris Bedoya
758 PointsIncompatible pointer types sending NSArray to parameter of type NSString (JSON parsing)
Im working on an app using the Blog Reader App as a starting point. I'm trying to show an image and I got it to work but I get this error:
Incompatible pointer types sending NSArray to parameter of type NSString (JSON parsing)
I know its because my image property "thumb" is an Array and not a String, but I dont know how to change the code so the error could go away.
@property (nonatomic, strong) NSArray *thumb;
- (NSURL *) thumbURL {
return [NSURL URLWithString: self.thumb]; (The error points to "self")
}
Thanks.
1 Answer

Amit Bijlani
Treehouse Guest TeacherThe first question is why is your thumb
an NSArray
and not an NSString
? To change it all you have to change the class name from NSArray
to NSString
@property (nonatomic, strong) NSString *thumb;
Chris Bedoya
758 PointsChris Bedoya
758 PointsMy thumb is an NSArray because of the way my JSON is set up, and I know thats the reason I get the warning. I just want change this code so I stop getting the warning.
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherIf it's an array of strings then you need to access the individual element within the array. You can access an element within the array using the method
objectAtIndex
. So you would access an element within your array:[self.thumb objectAtIndex:0]
. If you want to know more about arrays then check out this video: http://teamtreehouse.com/library/ios-development/build-an-iphone-crystal-ball-app/learning-the-language/getting-to-know-arrays