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];
1
  • This is a very simple question and could easily be answered with some basic research Commented Oct 23, 2013 at 22:35

1 Answer 1

1

Try this :

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

or

textView.text = [list objectAtIndex:count]; 
Sign up to request clarification or add additional context in comments.

2 Comments

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];.
The array already has a string. There is no need to format the string. So it is pointless to use stringWithFormat:.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.