Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2622622
  • 博文数量: 877
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5921
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-05 12:25
个人简介

技术的乐趣在于分享,欢迎多多交流,多多沟通。

文章分类

全部博文(877)

文章存档

2021年(2)

2016年(20)

2015年(471)

2014年(358)

2013年(26)

分类: iOS平台

2015-09-22 17:12:41

//

//  main.m

//  command

//

//  Created by Admin on 9/22/15.

//  Copyright (c) 2015 5. All rights reserved.

//


#import <Foundation/Foundation.h>

#import "Animal.h"


@interface myClass : NSObject


- (void)timeLoop:(NSTimer *)timer;


@end


@implementation myClass


- (void)timeLoop:(NSTimer *)timer

{

    NSLog(@"this is .....");

}


@end

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        

        Animal *dog = [[Animal alloc] init];

        

        myClass *m = [[myClass alloc] init];

        [NSTimer scheduledTimerWithTimeInterval:2.0 target:m selector:@selector(timeLoop:) userInfo:nil repeats:YES];

        

        while (1) {

            [[NSRunLoop currentRunLoop] run];

        }

        //NSLog(<#NSString *format, ...#>)

    

    }

    return 0;

}


#import <Foundation/Foundation.h>


typedef int(^MyBlock) (int);


@interface Person : NSObject


- (void)show;


@property(nonatomic, copy)NSString *name;

@property(nonatomic, strong)MyBlock myblock;


@end

#import "Person.h"


@interface Person ()


@end


@implementation Person


- (instancetype)init

{

    self = [super init];

    if (self) {

        //[self show];

    }

    return self;

}


- (void)show

{

    _myblock(20);

}


@end

#import <Foundation/Foundation.h>


@interface Animal : NSObject


@property(nonatomic, assign)NSUInteger type;


@end


#import "Animal.h"

#import "Person.h"


@implementation Animal


- (instancetype)init

{

    self = [super init];

    if (self) {

        Person *xiaoming = [[Person alloc] init];

        xiaoming.myblock = ^(int a){

            NSLog(@"the block num is %d", a);

            return a;

        };

        [xiaoming show];

        

        

    }

    return self;

}


@end

阅读(466) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~