Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEduardo Mejía
36,816 PointsValue of type 'NSUInteger' should not be used as format arguments.
I have 2 problems. First, when I write
NSLog(@"Retrieved %d messages", [self.messages count]);
A warning appears: "Value of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead".
The second problem is that my app crashes, this is my code:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
PFQuery *query = [PFQuery queryWithClassName:@"Messages"];
[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];
[query orderByDescending:@"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
if (error) {
NSLog(@"No mames hay un Error: %@ %@", error, [error userInfo]);
} else {
self.messages = objects;
[self.tableView reloadData];
NSLog(@"Retrieved %d messages",[self.messages count]);
}
}];
}
These are the errors: https://www.dropbox.com/s/uxh5oyf0d0uc8jp/Ribbit.tiff?dl=0 https://www.dropbox.com/s/npmin6291facxek/Ribbit2.tiff?dl=0
And this is my class Messages: https://www.dropbox.com/s/oc0jbdap3ey4mq1/Parse.tiff?dl=0
Please I need help. I don't know what I'm doing wrong.
1 Answer
landonferrier
25,097 PointsEduardo, here is a full template for the social network application: Click Here.
Eduardo Mejía
36,816 PointsEduardo Mejía
36,816 PointsI found the solution, for the first problem Xcode suggested this:
NSLog(@"Retrieved %lu messages",(unsigned long)[self.messages count]);
For the second problem I was reading the documentation and changed my code to this:
But... Why does the Ben's code work? I need an explanation. My English isn't that good, so I'm going to write in Spanish. En la documentación aparecen dos ejemplos de como buscar un elemento en un array:
¿Por qué el primero le funciona a Ben pero a mi no, hace que la app tenga todos los errores que he mostrado anteriormente? ¿Por qué el segundo si me funciona si son dos formas distintas de hacer lo mismo?