顯示具有 iOS 標籤的文章。 顯示所有文章
顯示具有 iOS 標籤的文章。 顯示所有文章

2012年2月9日 星期四

App Idea:中文習字帖

性質雷同軟體:
1. Chinese Flash - Study & Learn Mandarin Vocabulary
http://itunes.apple.com/us/app/id486531735?mt=8

2. Pleco Chinese Dictionary
http://itunes.apple.com/us/app/pleco-chinese-dictionary/id341922306?mt=8

3. Learning to Write Chinese Characters on the iPad
http://www.sinosplice.com/life/archives/2011/06/30/learning-to-write-chinese-characters-on-the-ipad

4. eStroke
http://fast.eon.com.hk:1818/estroke/

iOS 開發資源
1. Tesseract OCR
http://iphone.olipion.com/cross-compilation/tesseract-ocr

2. Compiling tesseract v3 for iPhone
http://robertcarlsen.net/tag/tesseract

3. 中文筆順學習軟體製作
http://w2.hwc.edu.tw/ifg/dgn/98-7-3index.htm

4. 怎么样将汉字画出来
http://www.qqgb.com/Program/VC/VCJC/Program_237704.html

5. 筆順學習網
http://stroke-order.learningweb.moe.edu.tw/home.do

6. 中文字的筆順
http://chinesedigger.blogspot.com/2008/06/writing-sequences.html

2012年2月8日 星期三

iOS App 上架需知

Required iPhone & iPod touch Screenshot Upgrade for Retina Display
When you create or update your apps in iTunes Connect, you must upload screenshots that are high-resolution. We require your screenshots as high-resolution images so that your app is optimized for the Retina display.
The requirements for high-resolution images are 960 x 640, 960 x 600, 640 x 960, or 640 x 920 pixels. Images must be at least 72 dpi, in the RGB color space, and the file must be .jpeg, .jpg, .tif, .tiff, or .png. You can update your screenshot files at any time in iTunes Connect.

New Notification for Binaries Exceeding Cellular Network Download Size Limit
Admin and Technical users will now be notified if your resulting binary size for the App Store exceeds the cellular network download size limit of 20MB. Exceeding the limit requires your app to be downloaded over Wi-Fi. This information can help you determine if you want to resubmit your binary in order to reduce the size of your app.

2012年1月9日 星期一

[super dealloc]; 使用注意事項

在 ObjC 的類別中,物件消滅時會呼叫

- (void)dealloc {

[super dealloc];

}

通常我們會將需要釋放的資源也寫在裡面,進行資源的釋放,
特別要注意的是 [super dealloc]; 要最後才呼叫。


錯誤(會造成釋放失敗系統當掉)
- (void)dealloc {

[super dealloc];

[myobj release];
[myobj2 release];

}



正確寫法應該為
- (void)dealloc {

[myobj release];
[myobj2 release];

[super dealloc];
}

2011年11月28日 星期一

NSDate Top usage

Here is NSDate top usage:

// Your dates:
NSDate * today = [NSDate date];
NSDate * yesterday = [NSDate dateWithTimeIntervalSinceNow:-86400]; //86400 is the seconds in a day
NSDate * refDate; // your reference date

// 10 first characters of description is the calendar date:
NSString * todayString = [[today description] substringToIndex:10];
NSString * yesterdayString = [[yesterday description] substringToIndex:10];
NSString * refDateString = [[refDate description] substringToIndex:10];

if ([refDateString isEqualToString:todayString]) 
{
    cell.title.text =  @"Today";
} else if ([refDateString isEqualToString:yesterdayString]) 
{
    cell.title.text =  @"Yesterday";
} else 
{
    cell.title.text =  refDateString;
}

2011年9月2日 星期五

Hints for publish IPA (iOS app)

由於團隊中申請的帳號可能會有多組,
在建立 IPA 檔案準備要發佈至 App Store 或透過 In-House 方式時,
有時候會因位憑證簽署太多組導致混淆,
我們可以透過檢查以下兩個部份來作最後的檢查:

In build detail view

1. 尋找字串 embedded.mobileprovision,檢查是否存在於 builded package中。
2. 尋找字串 CodeSign,檢查 "iPhone Distribution: Your CodeSign Name." 是否正確。

如此,就能確保 IPA 檔案是正確的。

2011年8月26日 星期五

Remove UIViewController from UINavigationController


NSMutableArray *allControllers = [[NSMutableArray alloc] initWithArray:navPick.viewControllers];
for (id object in allControllers) {
// if ([object isKindOfClass:[LoginController class]]) // 此行註解掉,會將容器內所有VC移除
[allControllers removeObject:object];
}
navPick.viewControllers = allControllers;

2011年8月24日 星期三

Loaded the "NibFileName" nib but didn't get a UITableView

-[UITableViewController loadView] loaded the "NibFileName" nib but didn't get a UITableView

動態載入時 xcode 會報錯,原因是繼承的形態跟 nib 使用的類別不同造成,
原始的宣告如下:


@interface ObjIDPickViewController : UITableViewController
{
}


要把它改成


@interface ObjIDPickViewController : UIViewController
{
}

2011年8月13日 星期六

Why NSString* retainCount is 2147483647

先來看以下這段程式碼:

NSString *test1 = @"Test string";
NSLog(@"test1 retain count is: %d", [test1 retainCount]);	// 2147483647
[test1 retain];
NSLog(@"test1 retain count is: %d", [test1 retainCount]);	// 2147483647
[test1 release];
NSLog(@"test1 retain count is: %d", [test1 retainCount]);	// 2147483647

恩,你沒看錯,印出來的 retainCount 都是 2147483647,
接著我們再來看下面這段程式碼:

NSString *test2 = [[NSString alloc] initWithString:@"Test string"];
NSLog(@"test 2 retain count is: %d", [test2 retainCount]);	// 猜猜看
[test2 retain];
NSLog(@"test 2 retain count is: %d", [test2 retainCount]);	// 猜猜看
[test2 release];
NSLog(@"test 2 retain count is: %d", [test2 retainCount]);	// 猜猜看


恩,印出來的值有符合預期的物件參考值:1 2 1 嗎?
答案是沒有,同樣都是 2147483647 這個神奇數字,這個數字到底是什麼東西呢?

其實上述的寫法,在經過 xcode compiler 編譯之後,都會把它改成一個指向常數字串的指標,
而這個神奇的數字,就是因為指標指向常數的時候,使用 retainCount 只會印出 UINT_MAX,
實際上看以下的圖就會更瞭解:



接著再來看這段程式碼:

NSString *test3 = [[NSString alloc]initWithFormat:@"%@", @"Test string"];
NSLog(@"test 3 retain count is: %d", [test3 retainCount]);	// 1	
[test3 retain];
NSLog(@"test 3 retain count is: %d", [test3 retainCount]);	// 2
[test3 release];
NSLog(@"test 3 retain count is: %d", [test3 retainCount]);	// 1	

這樣就有符合預期的參考值了,差異就在 initWithFormat 這個初始字串的方式,
看出差異了嗎?

2011年8月11日 星期四

Xcode crush

不管是 MS Visual Studio, Apple Xcode, Java Eclipse 全部都被我操到當掉,該自豪嗎...

NSString 常用操作範例


1.字串比較
NSString *str1 = [[NSString alloc]initWithString:@"I am String1"];
NSString *str2 = [[NSString alloc]initWithString:@"I am String2"];
NSLog(@"%@ 與 %@ 是否相同: %@", str1, str2, [str1 isEqualToString:str2] ? @"Y":@"N");
[str1 release];
[str2 release];


2.字串比較(不區分大小寫)
NSString *str1 = [[NSString alloc]initWithString:@"I am String1"];
NSString *str2 = [[NSString alloc]initWithString:@"i am string1"];
NSLog(@"%@ 與 %@ 是否相同(不考慮大小寫): %@", str1, str2,
[str1 caseInsensitiveCompare:str2]==NSOrderedSame ? @"Y":@"N");
[str1 release];
[str2 release];

3.搜尋字串
NSString *str1 = [[NSString alloc]initWithString:@"This is an apple"];
//此處NSRange 為區分大小寫
NSRange searchString1 = [str1 rangeOfString:@"apple"];
NSRange searchString2 = [str1 rangeOfString:@"orange"];
NSLog(@"%@ 是否有apple字串: %@",str1, searchString1.location == NSNotFound ? @"N" : @"Y" );
NSLog(@"%@ 是否有orange字串: %@",str1, searchString2.location == NSNotFound ? @"N" : @"Y" );
[str1 release];

4.取出字串
NSString *str1 = [[NSString alloc]initWithString:@"this is a string"];
NSLog(@"%@ 取出從頭自第2位(不包含第2位)的字串: %@",str1, [str1 substringToIndex:1]);
NSLog(@"%@ 取出第2位(包含) 後所有字串: %@",str1, [str1 substringFromIndex:1]);
NSLog(@"%@ 取出第3位至第7位的字串: %@",str1, [str1 substringWithRange:NSMakeRange(5,4)]);
[str1 release];

5.替換字串
NSString *string1 = [[NSString alloc]initWithString:@"this is a book"];
NSString *string2 = [[NSString alloc]initWithString:@"pen"];
NSLog(@"%@ 替換後 %@",string1,
[string1 stringByReplacingOccurrencesOfString:@"book" withString:@"pen"]);
[string1 release];
[string2 release];

6.字串轉成array
NSString *str1 = [[NSString alloc]initWithString:@"apple,orange,cat,dog,bird"];
NSLog(@"%@",[str1 componentsSeparatedByString:@","]);
[str1 release];

7.array轉成字串
NSArray *array = [[NSArray alloc]initWithObjects:@"apple",@"orange",@"cat",@"bird",nil];
NSLog(@"%@",[array componentsJoinedByString:@","]);
[array release];

NSString 轉換為 NSDate

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:@"2010-08-04 16:01:03"];
NSLog(@"%@", date);
[dateFormatter release];

2011年8月4日 星期四

sendSynchronousRequest 狀態下如何顯示忙碌訊息

NSURLConnection 類別中的 sendSynchronousRequest 方法,
是一個同步處理的機制,也就是說當此方法ㄧ被呼叫,該執行緒就會被整個咬住了,
通常來說我們會希望能加入一些畫面提醒的機制(例如轉圈圈),有兩種解決來提供:

解法一(程式碼可以改最少):
- (void)loadInOnePart {

//...other real code

UIAlertView *avBusy = [[[UIAlertView alloc] initWithTitle:@"Busy busy" message:nil delegate:nil
cancelButtonTitle:nil otherButtonTitles:nil] autorelease];
[avBusy show];

UIActivityIndicatorView *aiBusy = [[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
[aiBusy startAnimating];
[avBusy addSubview:aiBusy];

aiBusy.center = CGPointMake(avBusy.bounds.size.width / 2, avBusy.bounds.size.height / 2 + 10);

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];

[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

[avBusy dismissWithClickedButtonIndex:0 animated:YES];
}

解法二(程式碼分割要考慮整體架構):
- (void)loadPart1 {
activityIndicator = [[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]
autorelease];
[self.view addSubview:activityIndicator];
[activityIndicator startAnimating];
[self performSelector:@selector(loadPart2) withObject:nil afterDelay:0];
}

- (void)loadPart2 {
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
[activityIndicator stopAnimating];
}


參考資料來源