2011年11月2日 星期三

IPhone - Objective C 學習參考網站




    iOS开发者















Using TBXML have Link error

using TBXML have the error:

Undefined symbols for architecture i386:
  "_deflateInit2_", referenced from:
      -[ASIDataCompressor setupStream] in ASIDataCompressor.o
  "_deflateEnd", referenced from:
      -[ASIDataCompressor closeStream] in ASIDataCompressor.o
  "_deflate", referenced from:
      -[ASIDataCompressor compressBytes:length:error:shouldFinish:] in ASIDataCompressor.o
  "_inflateInit2_", referenced from:
      -[ASIDataDecompressor setupStream] in ASIDataDecompressor.o
  "_inflateEnd", referenced from:
      -[ASIDataDecompressor closeStream] in ASIDataDecompressor.o
  "_inflate", referenced from:
      -[ASIDataDecompressor uncompressBytes:length:error:] in ASIDataDecompressor.o
  "_OBJC_CLASS_$_OMAppMeasurement", referenced from:
      objc-class-ref in OmnitureService.o

ANS:
1 [Link Binary With Libaries] Add libz.1.5.dylib
http://stackoverflow.com/questions/7118474/help-me-out-with-error-deflateinit2

2.Add Libraries - step by step:
http://allseeing-i.com/ASIHTTPRequest/Setup-instructions

2011年11月1日 星期二

tbxml - parse XML

http://istarelworkshop.com/2011/06/17/using_the_tbxml_library


http://stackoverflow.com/questions/5406424/iphone-tbxml-looping-and-parsing-data


http://ntt.cc/2010/09/05/50-open-source-iphone-apps-for-iphone-developers.html

NSString 是 Object C 中常用的類。在這裡,在網路上搜集整理一些關於 NSString 的操作供參考:
  • 添加 '@' 在字串前變成 NSString
NSString \*t = @"test"
  • 連接

字串連接有三種方法:

NSString *string1; NSString\* string2;

1. NString *compose = [NSString initWithFormat:@"%@,%@", string1, string2 ];

2. NString *compose = [string1 stringByAppendingString:string2];

3 . NString *compose = [string stringByAppendingFormat:@"%@,%@",string1, string2];

其中 format 的格式為:

'%@' 是格式化 NSString 類型

%d, %D, %i 是格式化 32位元有符號整數 (int)

具體見參考手冊
  • Format (initWithFormat & stringWithFormat)

NSString *string = [[NSString alloc] initWithFormat:@"%@", otherString];

label.text = string;

[string release];  //使用alloc不要忘記release掉!

myStr = [NSString stringWithFormat:@"%@", otherStr2];
  • 轉換(從別的型態轉至NSString)
int 到 NSString: [NSString stringWithFormat:@"%d", myInt];

NSInteger 到 NSString: [NSString stringWithFormat:@"%d", [myNSInt intValue]];


  • 比對(兩個字串比對)

if ([textField.text isEqualToString: @""]) {
        textField.text = @"0";
    }

不是用 textField.text! == @"";  來比對喔!  complier會過,但執行不理你!