2016年4月29日 星期五

iOS tips - add delay

寫app時,不管是為了加上一些效果,或者是解一些奇怪的bug,常會需要加上delay然後來處理我們之後想要做的code,下面這段code就是delay 2秒然後處理另外的task

double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    //code to be executed on the main queue after delay
    [self doSometingWithObject:obj1 andAnotherObject:obj2];
});

2016年4月28日 星期四

iOS tips - PCH file in latest Xcode

記得好像Xcode 6之後PCH file在建project時就不會自動產生了,小弟不才,不知道把這拿掉的原因是啥,能夠有個標頭檔import常用到的file不是很好嗎?!下面這篇說明了要怎麼把pch file加回來.
http://stackoverflow.com/questions/24305211/pch-file-in-xcode-6