Legolas
Legolas

Reputation: 12325

Simple Issue with NSString Global Variables - HELP

Okay so here's my problem.

I have a two global NSString variables.

globalVariable1 //stores one string.
globalVariable2 //stores 3 strings 

globalVariable2 is concatenated using

[NSString stringWithFormat:@"%@, %@, %@", Item1, Item2, Item3];

I assign

[textField setText:globalVariable1] //NO ERROR //

but

[textField setText:globalVariable2] // ERROR //

Could anyone tell me what is going on ?

Upvotes: 0

Views: 150

Answers (1)

bensnider
bensnider

Reputation: 3772

You probably aren't retaining globalVariable2. Since the stringWithFormat: method will return an autoreleased object, you need to retain it after you assign it.

Upvotes: 2

Related Questions