Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

NSArray method and label declaration

Hi everybody

I hope I'm in the write place in the forum if im not so sorry for that im new in here. I have a question for you all.. Im creating a game and in the game i want programme ask the name to user for this i create :

-(IBAction)try:(id)sender{
label.text=textfield.text
}

This code make the name remember what i couldnt resolve is i have NSArray method for my speeches.Like:
-(void)sixthdongu{
[self speechArray];
if(sixthtoucCounterr==0){
NSString *selected = [theSpeech objectAtIndex:a6];
NSString *activeSpeech= [[NSString alloc] initWithFormat:@"%@", selected];
speech.text=activeSpeech;
[activeSpeech release];
}


-(void)speechArray{

mySpeech= [[NSArray alloc] initWithObjects:@"one",
@"two!",
@"three",
@"four",

nil];
self.theSpeech =mySpeech;

}

ok what i want is to put a %i sign inside of the array in the @"three" and i made it like this : @"three %i" ,label

but it didnt work at all...

i have maybe 30 class with this array method so if i can solve this my job will be really easy.

I hope i explain it simple.

Replies

  • mashercakesmashercakes Posts: 748Registered Users
    [self speechArray];
    This line doesn't do anything. You're sending a message to self to get the object called speechArray, but don't actually do anything with it.

    -(void)speechArray{

    mySpeech= [[NSArray alloc] initWithObjects:@"one",
    @"two!",
    @"three",
    @"four",

    nil];
    self.theSpeech =mySpeech;
    }
    You've got a memory leak here because you haven't released mySpeech.
    yigit87 said:

    ok what i want is to put a %i sign inside of the array in the @"three" and i made it like this : @"three %i" ,label

    So you want to have the word "three" and then the value of the label's text? If so, then this is how you would do it:
    NSString myString = [NSString stringWithFormat:@"three %@", [label text]];
    Post edited by mashercakes on
    TalkBoard - a communication aid and visual support app for children and adults with autism, communication difficulties or learning difficulties. Available now for iPad, iPhone and iPod Touch.
Sign In or Register to comment.