iOS 多线程

iOS--多线程--NSObject

2016-02-28  本文已影响22人  STONEsh

ViewController.m#

//
//  ViewController.m
// 多线程--NSObject
//

//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    //----------------------多线程NSObject---------------------------
    
    
//子线程:
    
    [self performSelectorInBackground:@selector(mutableThread:) withObject:@"didididididi"];
    
    
//主线程:
    
    for (int i = 0; i < 50; i ++) {
        NSLog(@"主线程:%d", i);
    }
    
}

//子线程调用方法
-(void)mutableThread:(NSString *)str{
    
    for (int i = 0; i < 50; i ++) {
        NSLog(@"子线程:%d", i);
        
    }
    NSLog(@"%@",str);
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

上一篇下一篇

猜你喜欢

热点阅读