2

I have declare a method in my .h file as

-(IBAction)buttonTapped:(id) sender;

and I apply this method in my .m file as

-(IBAction)buttonTapped:(id)sender
{
    NSString* themessage=[NSString stringWithFormat:@"I'm %@ and feeling %@ about it",[activities objectAtIndex:[tweetPicker selectedRowInComponent:0]],
                          [feelings objectAtIndex:[tweetPicker selectedRowInComponent:1]]];
    NSLog (themessage);

}

but at the line NSLog (themessage);

it shows me warning likd "format string is not string literal(potentially unsecure"

pls suggest me what i should do...

iPhone
  • 4,092
  • 3
  • 34
  • 58
  • possible duplicate of [Issue With Code: Format string is not a string literal](http://stackoverflow.com/questions/5428325/issue-with-code-format-string-is-not-a-string-literal) – highlycaffeinated Aug 11 '11 at 12:35

6 Answers6

3

You didn't specify a format string:

NSLog(@"%@", themessage);

Some useful examples of how to use the function on CocoaDev.

Perception
  • 79,279
  • 19
  • 185
  • 195
1

Try this:

  NSLog(@"Output : %@",themessage);
Devang
  • 11,258
  • 13
  • 62
  • 100
1

The first parameter to NSLog should be a format string, like @"I'm %@ and feeling %@", followed by the values for %@, %d, %f, etc:

-(IBAction)buttonTapped:(id)sender
{
    NSLog( @"I'm %@ and feeling %@ about it",
           [activities objectAtIndex:[tweetPicker selectedRowInComponent:0]],
           [feelings objectAtIndex:[tweetPicker selectedRowInComponent:1]] );
}
progrmr
  • 75,956
  • 16
  • 112
  • 147
1

Try This ..

-(IBAction)buttonTapped:(id)sender { NSString* themessage=[NSString stringWithFormat:@"I'm %@ and feeling %@ about it",[activities objectAtIndex:[tweetPicker selectedRowInComponent:0]], [feelings objectAtIndex:[tweetPicker selectedRowInComponent:1]]];

**NSLog (@"Output = %@ ",themessage);**

}

Ravi Chokshi
  • 1,106
  • 9
  • 18
1

You should have to give the reference of the data type. You are going to display message and that is type of string so you should have to write like below code:

NSLog(@"Output : %@",themessage);
user229044
  • 232,980
  • 40
  • 330
  • 338
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
0

Try that after allocating a string object via alloc.

Peter DeWeese
  • 18,141
  • 8
  • 79
  • 101
Arpit B Parekh
  • 1,932
  • 5
  • 36
  • 57