当前位置:  编程技术>移动开发
本页文章导读:
    ▪多台计算机使用同一个开发者账号        多台电脑使用同一个开发者账号 借此贴总结一下自己今天把一个证书放到两个机器上 的经历:http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/128-Managing_Devices_and_Digital_Ide.........
    ▪ UIButton上的图片、文字位置整合        UIButton上的图片、文字位置调整 UIButton上的图片和文字位置调整:  属性: imageEdgeInsets      contentEdgeInsetsUIEdgeInsetsMakeCreates an edge inset for a button or view.UIEdgeInsets UIEdgeInsetsMake ( .........
    ▪ Grand Central Dispatch 札记       Grand Central Dispatch 笔记 https://www.evernote.com/shard/s20/sh/54fbd735-53b6-4436-9bd4-88d46b628527/22bc221c73b55dbf1ddfb5515649c239     1. GCD 使用后不用程序去管理线程的开闭,GCD会在系统层面上去动态检测系统状态.........

[1]多台计算机使用同一个开发者账号
    来源: 互联网  发布时间: 2014-02-18
多台电脑使用同一个开发者账号

借此贴总结一下自己今天把一个证书放到两个机器上 的经历:
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/128-Managing_Devices_and_Digital_Identities/devices_and_identities.html

首先就是按照下面说的:
When you request a certificate from the iPhone Provisioning Portal, a public/private key pair is generated. The public key is included in your certificate. The private key is stored in your keychain. With these items, Xcode code-signs the applications you build with it. If you need to use another computer to develop iOS applications, you must transfer these digital-identification items to the other computer. You can do this in the Xcode Organizer.

To export your digital-identification items to a secure file, follow these steps:

Open the Xcode Organizer.
In the IPHONE DEVELOPMENT group, select Developer Profile.
Click Export Developer Profile.
Name the file, select a location for it, enter a password to secure the file, and click Save.
Now, when you need to develop iOS applications on another computer, import your digital-identification items into it by performing these steps:

Copy the developer-profile archive to the second computer.
On the second computer, launch Xcode.
Open the Organizer.
In the IPHONE DEVELOPMENT group, select Developer Profile.
Click Import Developer Profile.
Locate the archive, enter the password used to secure it, and click Open.

关键的一点就是不是直接从keychain里导出.cer文件,而是利用Xcode的organizer的IPHONE DEVELOPMENT ---》Developer Profile里自带的Export和Import操作,不知这个方法如果实用与三个或者10个电脑其不是很BUG


    
[2] UIButton上的图片、文字位置整合
    来源: 互联网  发布时间: 2014-02-18
UIButton上的图片、文字位置调整
UIButton上的图片和文字位置调整:
  属性: imageEdgeInsets
      contentEdgeInsets

UIEdgeInsetsMake
Creates an edge inset for a button or view.

UIEdgeInsets UIEdgeInsetsMake (
   CGFloat top,
   CGFloat left,
   CGFloat bottom,
   CGFloat right
);
Parameters
top
The inset at the top of an object.      距离顶部的间隔
left
The inset on the left of an object      距离左边的间隔
bottom
The inset on the bottom of an object.    距离底部的间隔
right
The inset on the right of an object.     距离右边的间隔

  

    
[3] Grand Central Dispatch 札记
    来源: 互联网  发布时间: 2014-02-18
Grand Central Dispatch 笔记

https://www.evernote.com/shard/s20/sh/54fbd735-53b6-4436-9bd4-88d46b628527/22bc221c73b55dbf1ddfb5515649c239

 

 

1. GCD 使用后不用程序去管理线程的开闭,GCD会在系统层面上去动态检测系统状态,开闭线程


2. Dispatch Queues   单行(放进去的task只会等前一个执行完了才会执行下一个) 并行(放进去的task不用等前一个执行完了,但他们开始执行的次序还是FIFO的) 2种  FIFO  把task依次放入单行queue可以实现顺序执行

3. Operation Queues 可以指定任务之间的优先级  task之间的先后依赖关系


4. __block变量是可以改变的 共享的

    dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);


    for (__block int i = 0; i<10000; i++) {

        dispatch_async(aQueue, ^{

            NSLog(@"%d",i);

        });

    }

2011-07-05 17:11:38.346 ttt[41418:1803] 61

2011-07-05 17:11:38.346 ttt[41418:5f03] 1292

2011-07-05 17:11:38.348 ttt[41418:1803] 4096

2011-07-05 17:11:38.348 ttt[41418:5f03] 4954

2011-07-05 17:11:38.349 ttt[41418:1803] 5823

2011-07-05 17:11:38.349 ttt[41418:5f03] 6159

2011-07-05 17:11:38.349 ttt[41418:1803] 6575

2011-07-05 17:11:38.349 ttt[41418:5f03] 6634

2011-07-05 17:11:38.350 ttt[41418:1803] 7936

2011-07-05 17:11:38.350 ttt[41418:5f03] 8428

2011-07-05 17:11:38.351 ttt[41418:1803] 8895

2011-07-05 17:11:38.351 ttt[41418:5f03] 9364

2011-07-05 17:11:38.351 ttt[41418:1803] 9836

2011-07-05 17:11:38.351 ttt[41418:5f03] 10000

2011-07-05 17:11:38.354 ttt[41418:1803] 10000

5. 普通的外部变量的值是task(block)被创建时的值(闭包)

    dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);


    for (int i = 0; i<1000; i++) {

        dispatch_async(aQueue, ^{

            NSLog(@"%d",i);

        });

    }

2011-07-05 17:15:37.525 ttt[41697:1803] 0

2011-07-05 17:15:37.526 ttt[41697:1803] 2

2011-07-05 17:15:37.527 ttt[41697:1803] 3

2011-07-05 17:15:37.527 ttt[41697:1803] 4

2011-07-05 17:15:37.527 ttt[41697:1803] 5

2011-07-05 17:15:37.527 ttt[41697:1803] 6

2011-07-05 17:15:37.526 ttt[41697:5f03] 1

2011-07-05 17:15:37.530 ttt[41697:5f03] 8

2011-07-05 17:15:37.530 ttt[41697:5f03] 9

2011-07-05 17:15:37.530 ttt[41697:5f03] 10

2011-07-05 17:15:37.530 ttt[41697:5f03] 11

2011-07-05 17:15:37.532 ttt[41697:6203] 13


6. queue可以有结束时执行的方法

void myFinalizerFunction(){

    NSLog(@"xxx");

}


- (void)viewDidLoad {

    [superviewDidLoad];

    

    

    dispatch_queue_t queue = dispatch_queue_create("com.example.MyQueue", NULL);

    dispatch_set_context(queue, @"xxx");

    dispatch_set_finalizer_f(queue, &myFinalizerFunction);

    for (int i = 0; i<1000; i++) {

        dispatch_async(queue, ^{

            NSLog(@"%d",i);

        });

    }

    dispatch_release(queue);


7. dispatch_sync(queue,task)  会阻塞当前线程 直到queue完成了你给的task, 但queue要完成你给的task,因为queue是FIFO的,意味着要完成之前的任务,才有机会执行你刚才给的task, 相当于当前线程等待queue里面所有任务执行完毕,  所以这句话不能在当前queue的任务代码里面调用,会造成死锁

    dispatch_queue_t queue = dispatch_queue_create("com.example.MyQueue", NULL);

    dispatch_set_context(queue, @"xxx");

    dispatch_set_finalizer_f(queue, &myFinalizerFunction);

    for (int i = 0; i<10; i++) {

        dispatch_async(queue, ^{

            NSLog(@"%d",i);

        });

    }

    NSLog(@"waiting");

    dispatch_sync(queue, ^{

        NSLog(@"wait done");

    });

    dispatch_release(queue);

2011-07-05 17:54:35.479 ttt[44203:207] waiting

2011-07-05 17:54:35.479 ttt[44203:1803] 0

2011-07-05 17:54:35.481 ttt[44203:1803] 1

2011-07-05 17:54:35.482 ttt[44203:1803] 2

2011-07-05 17:54:35.482 ttt[44203:1803] 3

2011-07-05 17:54:35.483 ttt[44203:1803] 4

2011-07-05 17:54:35.483 ttt[44203:1803] 5

2011-07-05 17:54:35.484 ttt[44203:1803] 6

2011-07-05 17:54:35.484 ttt[44203:1803] 7

2011-07-05 17:54:35.485 ttt[44203:1803] 8

2011-07-05 17:54:35.485 ttt[44203:1803] 9

2011-07-05 17:54:35.486 ttt[44203:207] wait done

2011-07-05 17:54:35.487 ttt[44203:1803] xxx


8. Waiting on Groups of Queued Tasks    //dispatch_sync只能对一个queue等待, group可以等好几个queue执行完

    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_group_t group = dispatch_group_create();

    

        // Add a task to the group

    dispatch_group_async(group, queue, ^{

        NSLog(@"first task");

    });

    

    dispatch_queue_t otherqueue = dispatch_queue_create("com.example.MyQueue", NULL);

    for (int i = 0; i<100; i++) {

        dispatch_group_async(group, otherqueue, ^{

            NSLog(@"otherqueue task");

        });

    }


    dispatch_group_wait(group, DISPATCH_TIME_FOREVER);


    NSLog(@"end waiting");


    dispatch_release(group);

2011-07-05 19:32:31.919 ttt[50138:5f03] otherqueue task

2011-07-05 19:32:31.919 ttt[50138:1803] first task

2011-07-05 19:32:31.922 ttt[50138:5f03] otherqueue task

2011-07-05 19:32:31.923 ttt[50138:5f03] otherqueue task

...

2011-07-05 19:32:32.078 ttt[50138:5f03] otherqueue task

2011-07-05 19:32:32.079 ttt[50138:5f03] otherqueue task

2011-07-05 19:32:32.080 ttt[50138:207] end waiting


9. Although you can obtain information about the underlying thread running a task, it is better to avoid doing so

10. 当你使用的是obj-c时, block会自动retain 被它包住的任何对象,当block执行完释放,所以你不必担心你在block内使用的obj-c对象会消失
当使用的是c时(CoreFoundation types in a C function), 你必须手动retain release,
void SaveArrayAsync(CFArrayRef array) {
    CFRetain(array);

    dispatch_queue_t queue = dispatch_get_global_queue(
                                 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_async(queue, ^{
        SaveToDisk(array);
        CFRelease(array);
    }
} 

11.  block的自动retain特性有时会造成互相引用,造成彼此都不能被释放, 可以用__block来解决这个问题,因为使用__block时不会retain
This copying/retaining semantics of blocks is very useful as it means your objects won’t go away while your block is being executed on some other thread, but you can also get into trouble if you happen to be using them only on one thread and the context in a block contains a reference to some parent structure. You’ll get into a retain-loop.
// inside your controller's tableView:cellForRowAtIndexPath:
cell = [[MyCell alloc] initWithBlock:^(MyCell* cell) {
           [self adjustCell:cell];
       }]; 
So here we have a block that calls a method on the controller. Simple enough. But when that cell is created, it’s init method might copy the block to ensure the block is valid at all times. The problem is, it references self. But that self is the view controller. So you have a view controller retained by one of its descendants. This creates a retained object loop that ultimately means this controller will never get released.

 __block variables are actually not retained when the lock is copied. So you can do this

// inside your controller's tableView:cellForRowAtIndexPath:
__block me = self;
cell = [[MyCell alloc] initWithBlock:^(MyCell* cell) {
           [me adjustCell:cell];
       }];

Since the self doesn’t get retained this time, we avoid the retain cycle. While it strikes me as iffy, it does work, and it’s the only way I’ve found to deal with this situation. You can’t simply avoid copying the block if you want to call it later, because the scope will be gone by the time the function that declared the block exits. That will lead to nothing but sadness.

1 楼 hhb19900618 2011-12-06  
呵呵 怎么搞不懂怎么去使用啊?

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3