iOS

warning: Creating default object from empty value in /var/www/www.waterworld.com.hk/modules/taxonomy/taxonomy.pages.inc on line 33.

NSExpression example

NSExpression is a very powerful class in iOS/OSX that calculate formula. We can also pass arguments or parameters to the formula:

NSExpression *expression1 = [NSExpression expressionWithFormat: @"1+2"];
NSLog(@"expression1 %@", [expression1 expressionValueWithObject:nil context:nil]);
NSExpression *expression2 = [NSExpression expressionWithFormat: @"1+%@-%@" argumentArray:@[@1.2, @2.2]];
NSLog(@"expression2 %@", [expression2 expressionValueWithObject:nil context:nil]);
NSMutableDictionary *context = [NSMutableDictionary dictionaryWithDictionary:

Free XCode plugins for XCode 4

Some opensource free plugins that you can add to your XCode to increase your productivity. All tested on the new XCode 4.6.

Mini Xcode Plugin
You know there is a fat toolbar at the top of the your windows since XCode 4. Although you can hide this tool bar, it will also hide the current project scheme and target. After installed this plugins, it will:
- add a popup menu at the top left or the windows that shows project scheme and target when tool bar is hidden.
- add shortcut (Ctrl+7, Ctrl+8) to select the schemes and targets.

Convert async block to sync

Since iOS 5, many apis will only provide block version and so we will get the result in async order. Sometimes we may want to get the result immediately by scarifying the benefit of GCD.

In old style, we can't do it using NSCondition:

__block NSCondition *condition = [[NSCondition alloc] init];
__block ALAssetsGroup *ret = nil;
ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {
[condition lock];
ret = group;
[condition signal];
[condition unlock];
};

Set priority in custom queue of GCD

In iOS GCD, you can use GCD queue to serialize operation by using DISPATCH_QUEUE_SERIAL parameters:

queue = dispatch_queue_create("hk.com.waterworld.previewRenderQueue", DISPATCH_QUEUE_SERIAL);

then you can create a queue dispatch like:

dispatch_async(self.renderQueue, ^{
... your code here ...
});

but the priority of the queue is unknown, so sometimes, when you queue a lot of task to this queue. It still block the foreground task and make the user interface not smooth.

If fix it, we can:

dispatch_async(self.renderQueue, ^{

香港 Passbook coupon (不定期更新)

Subway - 免費汽水
http://pass.is/subway

Seven Eleven - 購物折扣
http://711campaign.hk

iOS build architectures

In the latest Xcode, the build architectures is set to ARMv7 by default. Then it will not run on older models that using ARMv6.

ARMv6: iPhone 2G/3G, iPod 1stGen/2ndGen
ARMv7: iPhone 3GS or later, iPod 3rdGen or later, all iPad

So:

if only target for iPad:
ARMv7
else if only support 3GS or later/iPod 3rdGen or later:
ARMv7
else:
ARMv6 ARMv7

If you target for iPhone or iPhone/iPad and you will drop support for ARMv6 devices, you better set the following in the info.plist:

UIRequiredDeviceCapabilities: armv7

Behavior changed for parentViewController in iOS 5

Previously, if we present a modal view controller using:

[self presentModalViewController:modalViewController animated: YES]

We should able to get back the parent of the modal view controller using:

[modelViewController parentViewController]

and normally we will dismiss the view controller using:

[[modelViewController parentViewController] dismissModalViewControllerAnimated:YES];

iOS 4.3 airplay 新增功能

以前 iOS 4.2 只可以 stream ipod 和 youtube 入面的video,用途實在不大。今之 iOS 4.3 增加了 api 讓 developer 加 video airplay 功能。但另一方面,原來 Photos 入面已經加了很多 airplay 功能,不單可以看用iphone 拍下的video,還可以觀看相片。

iOS 4.1 Field Test 測試接收訊號

iOS 4.1 於九月九日已經發放了,原來之前關閉掉的 field test 功能又回來了,有什麼用呢? 它可以更準確地告訴你電話的訊號強弱,而不用用那個小小的訊號圖示。

在電話打出 *3001#12345#* 然後按 CALL
在電話打出 *3001#12345#* 然後按 CALL

Syndicate content