UI07_数据处理

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

AppDelegate.m

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate
- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    [_window release];

    NSString *path = [[NSBundle mainBundle] pathForResource:@"activitylist" ofType:@"txt"];
    NSData *data = [NSData dataWithContentsOfFile:path];

    NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

    NSLog(@"%@", dic[@"events"][2][@"title"]);
    NSLog(@"%@", dic[@"events"][2][@"begin_time"]);
    NSLog(@"%@", dic[@"events"][2][@"end_time"]);

    NSArray *arr = dic[@"events"];

    for (NSDictionary *dic in arr) {
        NSLog(@"%@", dic[@"loc_name"]);
    }


    for (NSDictionary *dic in arr) {
        NSLog(@"%@", dic[@"owner"][@"name"]);
    }



    return YES;
}
UI线程和数据处理线程是在Android开发常见的两种线程。UI线程(也叫主线程)负责处理用户界面的更新和用户交互事件,包括布局、绘制和响应用户输入等操作。而数据处理线程(也叫后台线程或工作线程)则负责执行耗时的数据处理和网络请求等任务,以避免阻塞UI线程的运行。 在多线程的场景下,UI线程和数据处理线程之间的通信是一项重要的任务。引用展示了如何在后台线程UI线程发送数据,使用了Android系统的Handler机制。通过在UI线程定义一个Handler对象,并在数据处理线程使用Handler发送消息,可以实现将数据传递给UI线程并在UI线程展示结果。 这种方式可以解决在UI线程和数据处理线程之间通信的问题,避免了界面假死和程序崩溃等情况的发生。使用display.syncExec(new Runnable())函数可以在基于UI界面的另开线程调用UI相关的操作,从而提高编程效率。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [SWT UI线程下另开线程执行数据处理和发送功能(多线程处理)](https://blog.csdn.net/snadijssajskkj/article/details/50483873)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [Android后台线程和UI线程通讯实例](https://download.csdn.net/download/weixin_38625098/14916312)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值