1. AppDelegate.m

 #import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[ViewController alloc] initWithNibName:@"SlowWorderView" bundle:nil];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
} - (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
} - (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
} - (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
} - (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
} - (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} @end

2. ViewController.h

 #import <UIKit/UIKit.h>

 @interface ViewController : UIViewController

 @property (weak, nonatomic) IBOutlet UIButton *startButton;
@property (weak, nonatomic) IBOutlet UITextView *resultsTextView; @end

3. ViewController.m

 #import "ViewController.h"

 @interface ViewController ()

 @end

 @implementation ViewController

 - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (NSString *)fetchSomethingFromServer {
[NSThread sleepForTimeInterval:];
NSURL *url = [NSURL URLWithString:@"http://nycode.sinaapp.com/d.php"];
NSError *error = nil; NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSDictionary *arr = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
return [arr objectForKey:@"name"];
} - (NSString *)processData:(NSString *)data {
[NSThread sleepForTimeInterval:];
return [data uppercaseString];
} - (NSString *)calculateFirstResult:(NSString *)data {
[NSThread sleepForTimeInterval:];
return [NSString stringWithFormat:@"Number of chars %lu", [data length]];
} - (NSString *)calculateSecondResult:(NSString *)data {
[NSThread sleepForTimeInterval:];
return [data stringByReplacingOccurrencesOfString:@"E" withString:@"e"];
} - (IBAction)doWork:(id)sender {
NSDate *startTime = [NSDate date];
NSString *fetcheData = [self fetchSomethingFromServer];
NSString *processdData = [self processData:fetcheData];
NSString *firstResult = [self calculateFirstResult:processdData];
NSString *secondResult = [self calculateSecondResult:processdData];
NSString *resultsSummary = [NSString stringWithFormat:@"First:[%@]\tSecond:[%@]", firstResult, secondResult];
self.resultsTextView.text = resultsSummary;
NSDate *endTime = [NSDate date];
NSLog(@"Complete in %f seconds", [endTime timeIntervalSinceDate:startTime]);
} @end

4. xib文件放一个textview和button并关联输出口和方法

5. 小结

应用程序启动后,程序会运行10秒。

控制台会显示运行的时间间隔

最新文章

  1. [译]Writing Custom Middleware in ASP.NET Core 1.0
  2. Contiki学习笔记  第一个程序:Hello World
  3. linux文件编码
  4. Android JNI之调用JAVA方法的返回类型签名
  5. [C语言(VC)] 打造自己的键盘记录器 (zaroty)
  6. 2014-07-31 ASP.NET的母版页使用
  7. Js 自定义回调函数
  8. 调整 CComboBox 控件的下拉列表的高度
  9. Qt打开外部程序和文件夹需要注意的细节(Qt调用VC写的动态库,VC需要用C的方式输出函数,否则MinGW32编译过程会报错)
  10. 用python实现模拟登录人人网
  11. The Problems of Mysql Installation
  12. hdu 5016 点分治(2014 ACM/ICPC Asia Regional Xi&#39;an Online)
  13. SpringCloud学习之SpringCloudBus
  14. ASP.Net Core开发(踩坑)指南
  15. Selenium3+python几种定位元素的方法
  16. struts2 contextMap
  17. 利用nodejs安装并运行express的三个坑
  18. request.GetResponse()超时的解决办法
  19. MVC实现加载更多
  20. Vue学习笔记:Slot

热门文章

  1. 动量Momentum梯度下降算法
  2. 19-python 自己建立词库并实现文章汉语词频统计
  3. [Selenium]计算坐标进行拖拽,重写dragAndDropOffset
  4. ffmpeg只编译h264
  5. RedHat6使用centos6的yum源
  6. Mac Sublime Text 浏览器 设置快捷键 让html文件在浏览器打开
  7. kinect相机做扫描仪扫描人体模型
  8. Intel Cyclone SoC FPGA介绍
  9. 报表导出jxls的使用笔记
  10. 简单配置vps,防ddos攻击