开发者

NSArray and Sandbox Question

开发者 https://www.devze.com 2022-12-15 21:10 出处:网络
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

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消