Tuesday, 15 March 2011

objective c - Using a message send to set `UILabel` text -


I read here how easy it is to set text through UILabel . The only issue is that I have the right syntax right now. I have to send a message, [myReciever readValue]; Used to check the value in that specific location, I am trying to set the text of UILabel to match the return value of that code. Here I have tried:

  self.myLabel.text = @ "% @", [myReciever readValue];   

^ This only sets the label as % @ .

  NSString * stringText = [myReciever readValue]; Self.myLabel.text = (@ "% @", string text);   

^ This text disappears completely Do anyone know how I can send a message to set the text of a UILabel ? In addition, the message returns a string .

Did you try:

  self.myLabel.text = [MyReceiver readValue]; You may have been trying to format the string:  
  self.myLabel.text = [NSString stringWithFormat: @ "% @", [ MyReceiver readValue]]; Of course this is useless because you already have the string using  stringWithFormat:  like it is the most formidable creation seen in the iOS section of the stack overflow.   

No comments:

Post a Comment