tags:

views:

20

answers:

2

I don't quite understand, but basically I am trying to click a button and have a value added to my NSMutableArray myArray which is a property. I thought my method that would be called when a button is pressed would be something like:

- (IBAction)addInterval {
 NSString *string = @"test";
 [self.myArray addObject:string];
}

But I don't understand why this doesn't work?

Also, is Wifi, volume control, and bluetooth all not in our sandbox to be used?thanks.

A: 

Could be one of a few things but the classic problem here is forgetting to connect the button to the action in interface builder. Have you checked that?

I'm also assuming that you've synthesized the myArray property so that you can use the dot notation.

Tom Duckering
+2  A: 

In general, in order for your IBAction to get called, it must have a parameter, e.g.

-(IBAction) addInterval: (id)sender {
}

Also, make sure you have bound the action to the button correctly inside the UI Designer - you should see it as an action outlet for the button.

To make sure your method is being called, stick a line in the method like:

NSLog(@"Called addInterval action");

Bluetooth will not work in sandbox, WiFi will work in the sense that the network connection will function, and the reachability example should help you here.

Chaos