0

I am trying to create a simple fact or joke app. It's simply not working. How do I get the UITextView to load a string, which is stored in an NSArray. Here is my code so far.

// Do any additional setup after loading the view, typically from a nib.
NSArray *list = [[NSArray alloc] initWithObjects:@"fact1",@"fact2",@"fact3",nil];
NSUInteger *count = 0;
textView.text = @"%@", [list objectAtIndex:count];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • This is a very simple question and could easily be answered with some basic research – Tim Oct 23 '13 at 22:35

1 Answers1

1

Try this :

textView.text = [NSSTring stringwithFormat:"%@",[list objectAtIndex:0]; 

or

textView.text = [list objectAtIndex:count]; 
  • Do not use the 1st option. It is pointless and inefficient. Simply assign the string like in the 2nd option. Better yet, use the modern syntax: `textView.text = list[count];`. – rmaddy Oct 24 '13 at 01:43
  • The array already has a string. There is no need to format the string. So it is pointless to use `stringWithFormat:`. – rmaddy Oct 24 '13 at 14:12