posts - 9,  comments - 0,  trackbacks - 0
          1.Add a new "revision.h"file
          2.Add a new Run script for the target 
          3.
           input the REV=`svnversion -nc | /usr/bin/sed -'s/^[^:]*://;s/[A-Za-z]//'`
          BASEVERNUM=`/usr/libexec/PlistBuddy -"Print :CFBundleShortVersionString" "${INFOPLIST_FILE}"`
          /usr/libexec/PlistBuddy -"Set :CFBundleVersion $BASEVERNUM.$REV" "${INFOPLIST_FILE}"

          4.clean the target and run
          posted @ 2011-08-15 12:11 雨 閱讀(280) | 評(píng)論 (0)編輯 收藏
          http://developer.apple.com/library/ios/#qa/qa1686/_index.html
          posted @ 2011-06-14 10:12 雨 閱讀(145) | 評(píng)論 (0)編輯 收藏

          1: 為工程運(yùn)行時(shí)加入 NSZombieEnabled 環(huán)境變量,并設(shè)為啟用,則在 EXC_BAD_ACCESS 發(fā)生時(shí),XCode 的 Console 會(huì)打印出問題描述。

          首先雙擊 XCode 工程中,Executables 下的 可執(zhí)行模組,


          在彈出窗口中,Variables to be set in the environment,添加 NSZombieEnabled,并設(shè)定為 YES,點(diǎn)擊選中復(fù)選框啟用此變量。

          這樣,運(yùn)行 Objective-C 時(shí)會(huì)看到控制臺(tái)輸出錯(cuò)誤信息

          這條消息對(duì)于定位問題有很好的提示作用。但是很多時(shí)候,只有這條提示是不夠的,我們需要更多的提示來幫助定位問題,這時(shí)候再加入 MallocStackLogging 來啟用malloc記錄。

          當(dāng)錯(cuò)誤發(fā)生后,在終端執(zhí)行:

          malloc_history ${App_PID} ${Object_instance_addr}

              則會(huì)獲得相應(yīng)的 malloc 歷史記錄,比如對(duì)于上一個(gè)控制臺(tái)輸出

          Untitled[3646:a0f] *** -[CFString release]: message sent to deallocated instance 0x10010d340

              則我們可以在終端執(zhí)行,結(jié)果如下:

          Buick-Wongs-MacBook-Pro:Downloads buick$ malloc_history 3646 0x10010d340
          malloc_history Report Version: 2.0
          Process: Untitled [3646]
          Path: /Users/buick/Desktop/Untitled/build/Debug/Untitled
          Load Address: 0×100000000
          Identifier: Untitled
          Version: ??? (???)
          Code Type: X86-64 (Native)
          Parent Process: gdb-i386-apple-darwin [3638]

          Date/Time: 2011-02-01 15:07:04.181 +0800
          OS Version: Mac OS X 10.6.6 (10J567)
          Report Version: 6

          ALLOC 0x10010d340-0x10010d357 [size=24]: thread_7fff70118ca0 |start | main | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | +[NSString initialize] | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | NXCreateMapTableFromZone | malloc_zone_malloc
          —-
          FREE 0x10010d340-0x10010d357 [size=24]: thread_7fff70118ca0 |start | main | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | _finishInitializing | free

          ALLOC 0x10010d340-0x10010d357 [size=24]: thread_7fff70118ca0 |start | main | -[NSPlaceholderString initWithString:] | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | _class_initialize | +[NSMutableString initialize] | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | NXCreateMapTableFromZone | malloc_zone_malloc
          —-
          FREE 0x10010d340-0x10010d357 [size=24]: thread_7fff70118ca0 |start | main | -[NSPlaceholderString initWithString:] | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | _class_initialize | _finishInitializing | free

          ALLOC 0x10010d340-0x10010d35f [size=32]: thread_7fff70118ca0 |start | main | -[NSCFString substringWithRange:] | CFStringCreateWithSubstring | __CFStringCreateImmutableFunnel3 | _CFRuntimeCreateInstance | malloc_zone_malloc

              這樣就可以很快的定位出問題的代碼片段了,注意輸出的最后一行,,,這行雖然不是問題的最終原因,但是離問題點(diǎn)已經(jīng)很近了,隨著它找下去,八成就會(huì)找到問題。

          posted @ 2011-02-21 09:51 雨 閱讀(379) | 評(píng)論 (0)編輯 收藏
           1 NSMutableString*tempString=[[NSMutableString alloc]initWithFormat:@"%@",@"testmemory"];
           2     NSLog(@"tempString retainCount-----%D",[tempString retainCount]);
           3     NSLog(@"tempString -----%p---%p",tempString,&tempString);
           4     
           5     NSMutableString*string1=[tempString retain];
           6     NSLog(@"string1 retainCount-----%D",[string1 retainCount]);
           7     NSLog(@"string1 -----%p---%p",string1,&string1);
           8     
           9     NSMutableString*string2=[tempString mutableCopy];
          10     NSLog(@"string2 retainCount-----%D",[string2 retainCount]);
          11     NSLog(@"string2 -----%p---%p",string2,&string2);
          12     
          13     
          14     NSString*s=[[NSString alloc]initWithFormat:@"%@",@"hello"];
          15     NSLog(@"s retainCount-----%D",[s retainCount]);
          16     NSLog(@"s -----%p---%p",s,&s);
          17     NSString*st=[s copy];
          18     NSLog(@"st retainCount-----%D",[st retainCount]);
          19     NSLog(@"st -----%p---%p",st,&st);
          20     NSString*str=[s retain];
          21     NSLog(@"str retainCount-----%D",[str retainCount]);
          22     NSLog(@"str -----%p---%p",str,&str);

          當(dāng)retain 時(shí)是表示指向了同一個(gè)內(nèi)存空間,只是內(nèi)存空間的retainCount加了1,其他的都沒變,但是當(dāng)copy時(shí),如果那個(gè)內(nèi)存單元里面的值是不可變的時(shí)候,我們跟retain是一樣的,只是內(nèi)存空間的retainCount加了1!如果那個(gè)內(nèi)存單元里面的值是可變的時(shí)候,其實(shí)在在內(nèi)存中另外給分配了一塊內(nèi)存空間,然后把值賦給內(nèi)存空間里面。原來那個(gè)內(nèi)存空間的retainCount不加1,現(xiàn)在新分配的內(nèi)存空間retainCount1.

          posted @ 2010-12-11 15:24 雨 閱讀(369) | 評(píng)論 (0)編輯 收藏
          程序發(fā)布的時(shí)候會(huì)因?yàn)橐恍﹏slog影響速度,所以在程序release的時(shí)候盡量把nslog去除掉。
          在程序中加入以下代碼即可

          #ifndef __OPTIMIZE__

          #    define NSLog(...) NSLog(__VA_ARGS__)

          #else

          #    define NSLog(...) {}

          #endif

          posted @ 2010-12-08 15:12 雨 閱讀(239) | 評(píng)論 (0)編輯 收藏
          最近把xcode升級(jí)后發(fā)現(xiàn)加入settingbundle取出的defaultValue一直是nil
          一直找不到原因
          所以就用以下方法了,希望能對(duì)大家有幫助

          -(void)initvalue
          {
              NSString 
          *url=[[NSUserDefaults standardUserDefaults] objectForKey:kConnection];
              
          if (url==nil) {
                  NSString 
          *stringBundle=[[NSBundle mainBundle] bundlePath];
                  NSString 
          *settingBundle=[stringBundle stringByAppendingPathComponent:@"Settings.bundle"];
                  NSString
          *listBundle=[settingBundle stringByAppendingPathComponent:@"Root.plist"];
                  NSDictionary
          *rootDict=[NSDictionary dictionaryWithContentsOfFile:listBundle];
                  NSArray
          *array=[rootDict objectForKey:@"PreferenceSpecifiers"];
                  NSDictionary
          *preItem;
                  NSString
          *connection=nil;
                  
          for (preItem in array) {
                      NSString
          *key=[preItem objectForKey:@"Key"];
                      id defaultValue
          =[preItem objectForKey:@"DefaultValue"];
                      
          if ([key isEqualToString:@"connection"]) {
                          connection
          =@" http://www.baidu.com";
                      }

                  }

                  NSDictionary 
          *dictionary=[[NSDictionary alloc]initWithObjectsAndKeys:connection,@"connection",nil];
                  [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
                  [[NSUserDefaults standardUserDefaults] synchronize];
                  [dictionary release];
                  [stringBundle release];
                  [rootDict release];
                  [preItem release];
              }

          }
          這只是初始化Root.plist里的值,在這里我加入了一個(gè)PSTextFieldSpecifier,
          posted @ 2010-10-28 09:11 雨 閱讀(1064) | 評(píng)論 (0)編輯 收藏
          一點(diǎn)點(diǎn)積累吧,第一次寫blog
          最近在學(xué)習(xí)ASIHttpRequest
          先認(rèn)識(shí)一下ASIHttpRequest
          如果要用到ASIHttpRequest先要向工程中加入CFNetwork.framework
          SystemConfiguration.framework, MobileCoreServices.framework, CoreGraphics.framework and libz.1.2.3.dylib
          然后再工程中加入所用到的包ASIHttpRequest
          接下來就可寫代碼了

          #import "TestAsiHttpreqeustViewController.h"
          #import 
          "ASIHTTPRequest.h"
          @implementation TestAsiHttpreqeustViewController


          -(void)viewDidLoad
          {
              ASIHTTPRequest
          *request=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@" http://172.16.20.14:8090/test.html"]];
              [request setDelegate:self];
              [request startSynchronous];
          }

          -(void)requestFinished:(ASIHTTPRequest *)request
          {
              NSString
          *responseString=[request responseString];
              NSLog(responseString);
          }

          這只是一個(gè)很簡單的ASIHttpRequest應(yīng)用,我也在研究中,呵呵,希望對(duì)初學(xué)者有一點(diǎn)幫助
          posted @ 2010-10-26 10:26 雨 閱讀(337) | 評(píng)論 (0)編輯 收藏
          <2010年10月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 延庆县| 兴业县| 大田县| 西峡县| 西和县| 新余市| 陆良县| 扎赉特旗| 宣化县| 洛宁县| 贵港市| 岳阳市| 建瓯市| 永康市| 鄂托克旗| 西丰县| 赞皇县| 舟曲县| 天柱县| 咸丰县| 桐柏县| 印江| 雅安市| 河池市| 宝清县| 通海县| 嘉定区| 康乐县| 梁山县| 佛坪县| 山西省| 保靖县| 天镇县| 启东市| 中山市| 黔江区| 威远县| 渝北区| 海南省| 澄江县| 定安县|