Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
07/29/12 05:17 AM (13 years ago)

Xcode update causing errors

My app store did an update to xcode yesterday. i think i am now on xcode4.4 now my project that i was working on with no errors, now has 12 cautions. can these be ignored as the app still builds OK?. They all refer to "Data argument not used by format string"
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
07/29/12 07:43 AM (13 years ago)
Very simple fix, go to the error, then it should say something like: NSLog(@"This is a very cool output too the console: ", someObject); (or) NSString *string = [NSString stringWithFormat:@"Very Cool Text", someObject]; In Either Event, you should change the code to look like: NSLog(@"This is a very cool output too the console: %@", someObject); (or) NSString *string = [NSString stringWithFormat:@"Very Cool Text %@", someObject]; Now you can compile and run this code and you will likely not get crashes or diminish your user experience because of it, however above is the fix. Please comment if the warning doesn't look like this.
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
07/29/12 10:04 AM (13 years ago)
worked perfect, thanks! basically just put %@ at the end of each message within the "......" thanks
 
JimmySaver
Aspiring developer
Profile
Posts: 187
Reg: Apr 09, 2012
location unknow...
5,870
like
08/03/12 02:22 PM (13 years ago)
Hi there, This fix seems to have worked for me too (though I haven't compiled yet). Just out of interest, do you know where the problem arises from? It seems silly that something as simple as a percentage symbol could wreck a project. I'll be honest though, I have no idea what the percentage mark refers to! Thanks for the fix @theMonster!
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
08/03/12 02:35 PM (13 years ago)
Lol, no problem. And the problem is that that's basically invalid code. It would be like saying "you pass ketchup" in english. Even though you can read it, something like a computer may misunderstand what your saying because it's not in the correct format. Here's a more technical explanation: When you create a string in objective-c you can include variables into it. You can for example add other strings into another string. This is what this code is doing: NSString *string = [NSString stringWithFormat:@"Very Cool Text %@", someObject]; When you drop the % sign, the computer doesn't know where to put the someObject string because it is not indicated by a %. So, to make it valid, you need the percent there to tell the computer, HEY! This is a String and put me at the @ sign!!! Hope that makes sense.
 
JimmySaver
Aspiring developer
Profile
Posts: 187
Reg: Apr 09, 2012
location unknow...
5,870
like
08/04/12 02:01 AM (13 years ago)
@theMonster, That's great, thanks so much for the explanation (it's nice when elements of the BT U course come back to me!). As someone who feels a bit sick when computer science and logic come into things, this explanation has helped a lot!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.