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 雨 阅读(269) | 评论 (0)编辑 收藏
http://developer.apple.com/library/ios/#qa/qa1686/_index.html
posted @ 2011-06-14 10:12 雨 阅读(135) | 评论 (0)编辑 收藏

1: 为工程运行时加入 NSZombieEnabled 环境变量,并设为启用,则在 EXC_BAD_ACCESS 发生时,XCode 的 Console 会打印出问题描述。

首先双击 XCode 工程中,Executables 下的 可执行模组,


在弹出窗口中,Variables to be set in the environment,添加 NSZombieEnabled,并设定为 YES,点击选中复选框启用此变量。

这样,运行 Objective-C 时会看到控制台输出错误信息

这条消息对于定位问题有很好的提示作用。但是很多时候,只有这条提示是不够的,我们需要更多的提示来帮助定位问题,这时候再加入 MallocStackLogging 来启用malloc记录。

当错误发生后,在终端执行:

malloc_history ${App_PID} ${Object_instance_addr}

    则会获得相应的 malloc 历史记录,比如对于上一个控制台输出

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

    则我们可以在终端执行,结果如下:

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

    这样就可以很快的定位出问题的代码片段了,注意输出的最后一行,,,这行虽然不是问题的最终原因,但是离问题点已经很近了,随着它找下去,八成就会找到问题。

posted @ 2011-02-21 09:51 雨 阅读(362) | 评论 (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);

retain 时是表示指向了同一个内存空间,只是内存空间的retainCount加了1,其他的都没变,但是当copy时,如果那个内存单元里面的值是不可变的时候,我们跟retain是一样的,只是内存空间的retainCount加了1!如果那个内存单元里面的值是可变的时候,其实在在内存中另外给分配了一块内存空间,然后把值赋给内存空间里面。原来那个内存空间的retainCount不加1,现在新分配的内存空间retainCount1.

posted @ 2010-12-11 15:24 雨 阅读(348) | 评论 (0)编辑 收藏
程序发布的时候会因为一些nslog影响速度,所以在程序release的时候尽量把nslog去除掉。
在程序中加入以下代码即可

#ifndef __OPTIMIZE__

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

#else

#    define NSLog(...) {}

#endif

posted @ 2010-12-08 15:12 雨 阅读(223) | 评论 (0)编辑 收藏
最近把xcode升级后发现加入settingbundle取出的defaultValue一直是nil
一直找不到原因
所以就用以下方法了,希望能对大家有帮助

-(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里的值,在这里我加入了一个PSTextFieldSpecifier,
posted @ 2010-10-28 09:11 雨 阅读(1047) | 评论 (0)编辑 收藏
一点点积累吧,第一次写blog
最近在学习ASIHttpRequest
先认识一下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);
}

这只是一个很简单的ASIHttpRequest应用,我也在研究中,呵呵,希望对初学者有一点帮助
posted @ 2010-10-26 10:26 雨 阅读(325) | 评论 (0)编辑 收藏

 

iphone中没有现成的下拉菜单,所以我只能用代码实现,写了小例子:

有一些对象没有进行release,童鞋们可自己稍加改动

/Files/linyu0324/Iphone/DropDown.zip
posted @ 2010-10-22 16:14 雨 阅读(184) | 评论 (0)编辑 收藏
判断当前设备:
Ipad:

#define isPad(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)

Mac&Iphone&Ipod:

#if TARGET_OS_IPHONE
NSLog(
@"iphone");
#elif TARGET_OS_MAC
NSLog(
@"mac");
#elif
NSLog(
@"other");
#endif

缩放图片:

-(UIImage *)scaleimage:(UIImage *)img size:(CGSize)c
{
    UIGraphicsBeginImageContext(c);
    [img drawInRect:CGRectMake(
00, c.width, c.height)];
    UIImage 
*image=UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
return image;
}
posted @ 2010-10-22 15:45 雨 阅读(226) | 评论 (0)编辑 收藏
仅列出标题  
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(1)

随笔档案

文章分类

搜索

  •  

最新评论

阅读排行榜

评论排行榜