iOS : Objective-C to Wax (OC 转 Wax) 笔记

//
//  OC2Wax.m
//  
//
//  Created by muzico on 16/3/26.
//
//


#pragma mark - 目录
/**
 创建一个UIViewController对象
 创建一个UIButton对象
 presentViewController
 dismissViewController
 
 MZCKit的使用
 mzcSendSelfMessage
 */

#pragma mark - 创建一个UIViewController对象
/*****************     创建一个UIViewController对象  START    ******************/
/*****
 Wax
 ****/
waxClass{"ViewController", UIViewController}

function dealloc(self)
  self.super:dealloc(self)

end

function init(self)
  self.super:init(self)

end

function loadView(self)
  self.super:loadView(self)

end

function viewDidLoad(self)
  self.super:viewDidLoad(self)

end

function viewWillAppear(self, animated)
  self.super:viewWillAppear(self, animated)

end

function viewDidAppear(self, animated)
  self.super:viewDidAppear(self, animated)

end

function viewWillDisappear(self, animated)
  self.super:viewWillDisappear(self, animated)

end

function viewDidDisappear(self, animated)
  self.super:viewDidDisappear(self, animated)

end

/*****
 OC
 ****/
@interface ViewController : UIViewController

@end

@implementation ViewController

- (void) dealloc
{
    [super dealloc];
    
}

- (id) init
{
    self = [super init];
    if(self) {
        
    }
    return self;
}

- (void) loadView
{
    [super loadView];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
}

- (void) viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    
}

@end
/*****************     创建一个UIViewController对象  END    ******************/

#pragma mark - 创建一个UIButton对象
/*****************     创建一个按钮  START    ******************/
/*****
 Wax
 ****/
self.myButton = UIButton:init()
self.myButton:setBackgroundColor(UIColor:redColor())
self.myButton:setTitle_forState("点击我进入下一页吧!",UIControlStateNormal)
self.myButton:addTarget_action_forControlEvents(self,"pressedButtonToDoSomething:",UIControlEventTouchUpInside)
self.myButton:setFrame(CGRect(10, 300, 320, 40))
self:view():addSubview(self.myButton)


function pressedButtonToDoSomething(self, sender)
    //do something
end

/*****
 OC
 ****/
@property(nonatomic,strong) UIButton* myButton;

self.myButton = [[UIButton alloc] init];
[self.myButton setBackgroundColor:[UIColor redColor]];
[self.myButton setTitle:@"点击我进入下一页吧!" forState:UIControlStateNormal];
[self.myButton addTarget:self action:@selector(pressedButtonToDoSomething:) forControlEvents:UIControlEventTouchUpInside];
[self.myButton setFrame:CGRectMake(10, 300, 320, 40)];
[self.view addSubview:self.myButton];

- (void) pressedButtonToDoSomething:(UIButton*) sender
{
    //do something
}
/*****************     创建一个按钮  END    ******************/

#pragma mark - presentViewController
/*****************     presentViewController  START    ******************/
/*****
 Wax
 ****/
local tempController = SecondController:init()
self:presentViewController_animated_completion(tempController, true, toblock(
     function()
        //do something
     end,{"void","void"}))
/*****
 OC
 ****/
UIViewController* tempViewController = [[UIViewController alloc] init];
[self presentViewController:tempViewController animated:YES completion:^{
    //do something
}];
/*****************     presentViewController  END    ******************/

#pragma mark - dismissViewController
/*****************     dismissViewController  START    ******************/
/*****
 Wax
 ****/
self:dismissViewControllerAnimated_completion(true, toblock(
    function()
        //do something
    end,{"void","void"}))

/*****
 OC
 ****/
[self dismissControllerAnimated:YES completion:^{
    //do something
}];
/*****************     dismissViewController  END    ******************/



#pragma mark - 
#pragma mark - MZCKit的使用
#pragma mark -
#pragma mark mzcSendSelfMessage
/*****************     mzcSendSelfMessage  END    ******************/
/*****
 Wax
 ****/
//在ViewController1
function pressedButtonToDoSomething(self, sender)
    local tempController = ViewController2:init()
    tempController:mzcReceiveSelfMessage(toblock(
        function(object)
            tempController:dismissViewControllerAnimated_completion(true, toblock(
                function()
                    //do something
                end,{"void","void"}))
        end,{"void","id"}))
    self:presentViewController_animated_completion(tempController, true, toblock(
         function()
             //do something
         end,{"void","void"}))
end
//在ViewController2
function pressedButtonToDoSomething(self, sender)

    self:mzcSendSelfMessage();

end

/*****
 OC
 ****/
//在ViewController1
- (void) pressedButtonToDoSomething:(UIButton*) sender
{
    ViewController2* tempController = [[ViewController2 alloc] init];
    [tempController mzcReceiveSelfMessage:^(id object) {
        [tempController dismissControllerAnimated:YES completion:^{
            //do something
        }];
    }];
    [self presentViewController:tempViewController animated:YES completion:^{
        //do something
    }];
}
//在ViewController2
- (void) pressedButtonToDoSomething:(UIButton*) sender
{
    [self mzcSendSelfMessage];
}
/*****************     mzcSendSelfMessage  START    ******************/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值