Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-23-2010, 04:31 PM   #1 (permalink)
cye
14 Year Old App Developer
 
Join Date: Mar 2010
Location: Texas
Posts: 242
cye is on a distinguished road
Default "format not a string literal and no format arguments" warning

i get this warning "format not a string literal and no format" but it doesnt seem to have an effect on my app.

Code:
	NSString *string = [[NSString alloc]initWithFormat:firstPrice.text];
__________________
14 year old app developer!

Type Faster and More Accurately With Easy Typing

"Like" me on facebook!

A+ FlashCards currently #6 Free Education app


Confidence is contagious. So is lack of confidence.
-- Vince Lombardi
cye is offline   Reply With Quote
Old 07-23-2010, 04:41 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 342
flamingliquid is on a distinguished road
Default

The string with format indicates that a variable argument list (va_list) should be passed in as the argument. Formats are used to place variables into a string and the first variable in the list should be an NSString with the formats (%@, %f, %i, %x, etc.). In your case change it to:
Code:
NSString *string = [[NSString alloc] initWithFormat:@"%@", firstPrice.text];
Maybe you don't need a format:
Code:
NSString *string = [[NSString alloc] initWithString:firstPrice.text];
Or much more simple, and uses less memory:
Code:
NSString *string = firstPrice.text;
Basically you are getting the warning because the method is marked with __attribute__((format(__NSString__, 1, 2))), which makes the compiler know that the first argument should be a literal NSString (@""), and in your case it isn't.
__________________
17 year old nerd.
Send me a PM. Maybe I can help.

Last edited by flamingliquid; 07-23-2010 at 04:44 PM.
flamingliquid is offline   Reply With Quote
Old 07-23-2010, 04:43 PM   #3 (permalink)
cye
14 Year Old App Developer
 
Join Date: Mar 2010
Location: Texas
Posts: 242
cye is on a distinguished road
Default thanks!

Quote:
Originally Posted by flamingliquid View Post
The string with format indicates that a variable argument list (va_list) should be passed in as the argument. Formats are used to place variables into a string and the first variable in the list should be an NSString with the formats (%@, %f, %i, %x, etc.). In your case change it to:
Code:
NSString *string = [[NSString alloc] initWithFormat:@"%@", firstPrice.text];
Maybe you don't need a format:
Code:
NSString *string = [[NSString alloc] initWithString:firstPrice.text];
Or much more simple, and uses less memory:
Code:
NSString *string = firstPrice.text;
thanks!
__________________
14 year old app developer!

Type Faster and More Accurately With Easy Typing

"Like" me on facebook!

A+ FlashCards currently #6 Free Education app


Confidence is contagious. So is lack of confidence.
-- Vince Lombardi
cye is offline   Reply With Quote
Reply

Bookmarks

Tags
arguments, error, format not a string, string, warnings

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 344
14 members and 330 guests
alexP, appservice, bignoggins, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, mariano_donati, Objective Zero, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:43 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0