可变的全球方法?

时间:2015-06-10 12:09:56

标签: objective-c iphone methods uibutton

我正在尝试在多个按钮中使用一个代码块,但是在我使用它的每个按钮中有四个整数值会发生变化。有人可以帮忙吗?

这是我的代码的简化部分,我得到Sigbart Thread错误或根本不会运行。 (我只需要使用块的帮助,我在其余代码中有正确的语法)

//。h file

@interface

@property BOOL playerTurn;
@property (weak, nonatomic) IBOutlet UILabel *firstPlayer;
@property (weak, nonatomic) IBOutlet UILabel *playerOneScore;
@property (weak, nonatomic) IBOutlet UILabel *playerTwoScore;
@property (weak, nonatomic) IBOutlet UITextField *playerTwoName;
@property (weak, nonatomic) IBOutlet UITextField *playerOneName;
@property (weak, nonatomic) IBOutlet UIButton *myButton00;
@property (weak, nonatomic) IBOutlet UIButton *myButton01;

- (IBAction)button00:(UIButton *)sender;
- (IBAction)button01:(UIButton *)sender;
- (void)pieceChanger;

//。m file

@implementation

- (void)pieceChanger
{
    NSArray *myButtons;
    myButtons = [NSArray arrayWithObjects: _myButton00, _myButton01,_myButton02,_myButton03,_myButton04,_myButton05,_myButton06,_myButton07,_myButton10,_myButton11,_myButton12,_myButton13,_myButton14,_myButton15,_myButton16,_myButton17,_myButton20, _myButton21,_myButton22,_myButton23,_myButton24,_myButton25,_myButton26,_myButton27,_myButton30,_myButton31,_myButton32,_myButton33,_myButton34,_myButton35,_myButton36,_myButton37,_myButton40,_myButton41,_myButton42,_myButton43,_myButton44,_myButton45,_myButton46,_myButton47,_myButton50,_myButton51,_myButton52,_myButton53,_myButton54,_myButton55,_myButton56,_myButton57,_myButton60,_myButton61,_myButton62,_myButton63,_myButton64,_myButton65,_myButton66,_myButton67,_myButton70,_myButton71,_myButton72,_myButton73,_myButton74, _myButton75,_myButton76,_myButton77,nil];

    int x;
    int rowMax;
    int rowMin;
    int diagMax;
    int diagMin;

    if(_playerTurn)
    {
        _myButton33.backgroundColor = [UIColor blackColor];

        _myButton33.tag = 1;

        for(int y = x; ((UIButton*)[myButtons objectAtIndex:y]).tag != 1 || y >= 0; y - 8)
        {
            if(((UIButton*)[myButtons objectAtIndex:y]).tag == 1)
            {
                for(int z = y; z <= x; z + 8)
                {
                    ((UIButton*)[myButtons objectAtIndex:z]).tag = 1;
                    ((UIButton*)[myButtons objectAtIndex:z]).backgroundColor = [UIColor blackColor];
                }
            }

        }(Continued)

- (IBAction)button00:(UIButton *)sender
{
    int x = 0;
    int rowMax = 7;
    int rowMin = 0;
    int diagMax = 0;
    int diagMin = 0;
    [button00.pieceChanger];
}

^这是我想要的,但我无法获得正确的语法。

谢谢!

0 个答案:

没有答案