2009 Archives

- (void)viewDidLoad {

    [super viewDidLoad];

CGRect frame= CGRectMake(520, 280, 320, 480);

CGImageRef small;

small= CGImageCreateWithImageInRect([[UIImage imageNamed:@"3.png"] CGImage],frame);

UIImageView *test=[[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:small]];

[self.view addSubview:test];

[test release];

}

[通知]MacGeeks 服务器恢复

| 1 Comment | No TrackBacks
 macgeeks.cn服务恢复。

请相互转告。


yarshure@gmail.com

日期:  11 月8日 下午2:00
地址:上海 长宁 万航渡路2453号 周家桥创意园B区
内容: iPhone 应用&游戏开发
       主题演讲1 游戏中使用OpenAL
dream2
上海骏梦网络科技有限公司 http://www.thedream.cc/ 
联系人:孔祥波  yarshure@gmail.com
http://www.commandguru.com/event200912/
Mr. Aaron Hillegass 的书籍
活动介绍:
Magic event for 10 Indie Developers
With the compliments of Aaron Hillegass and Command Guru

Command Guru will hold a 7 days, full immersion iPhone development session near Venice, Italy.

The development team leader will be Mr. Aaron Hillegass.

Dates: from december 6 to 12.
Location: by our big friends @ Big Rock (an H-Farm company)

Developers required skills:

  • fluent Obj-C (min. 3 years experience);
  • memory management (no garbage collector spoken here);
  • Maps + GPS;
  • network programming (socket, ports, etc...);
  • Core Data;
  • fluent spoken English;
  • workgroup attitude.

Skills that make you shine:

  • Push notifications;
  • inApp Purchase;
  • media playback.

UI designers are needed too.

For this first project we'll select 10 people only.
[UPDATE: only 3 seats left]

International Developers Welcome!

Free RedBull, Red wine (Italian...) and PIZZA.
Two way Airplane tickets + room included!

It will be a 7-day full-immersion development madness!
 

Reblog this post [with Zemanta]

iPhone GUI PSD 3.0

| No Comments | No TrackBacks
更新内容: Some of the changes and additions in the 3.0 PSD include: • Map and map elements including curl • Copy and paste elements • Timeline bar editor • Horizontal iPhone • Horizontal Panels bars and keyboards 

NSMutableArray 排序

| No Comments | No TrackBacks

- (NSArray *)sortedArrayUsingSelector:(SEL)comparator

Parameters
comparator

A selector that identifies the method to use to compare two elements at a time. The method should returnNSOrderedAscending if the receiver is smaller than the argument, NSOrderedDescending if the receiver is larger than the argument, and NSOrderedSame if they are equal

NSArray *sortedArray =
    [anArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];


@property (nonatomic, readwrite, retain) NSMutableArray *parameters;

[self.parameters sortUsingSelector:@selector(compare:)];



#pragma mark -


- (NSComparisonResult)compare:(id)inObject {

     NSComparisonResult result = [self.name compare:[(MPURLRequestParameter *)inObject name]];

     if (result == NSOrderedSame) {

result = [self.value compare:[(MPURLRequestParameter *)inObject value]];

     }

 

      return result;

}


//////////////////////////////////////////////////////////

sortedArrayUsingFunction:适合基本类型(支持compare方法)

#pragma mark SORT METHOTDS

NSInteger sortObjectsByLatestTime(id obj1, id obj2, void *context)

{


NSDate* d1 = [(MessageGroup*)obj1 latestTime];

NSDate* d2 = [(MessageGroup*)obj2 latestTime];

//sort by desc

return [d2 compare:d1];

}


NSInteger dateSort(id obj1, id obj2, void *context)

{

NSDate* d1 = ((Inbox*)obj1).datetime;

NSDate* d2 = ((Inbox*)obj2).datetime;

return [d1 compare:d2];

}

////////////////////////////////////////////////////////////////////


-(NSArray*)sortedMessages

{

return [[groupMessages allValues] sortedArrayUsingFunction:sortObjectsByLatestTime context:NULL];

}

//////////////////////////////////////////////////////////

sortUsingDescriptors:适合元素是dict类型,initWithKey既是dict key.

NSMutableArray *regions = [NSMutableArray array];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];

NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];

[regions sortUsingDescriptors:sortDescriptors];

[sortDescriptor release];



NSMutableData *data1, *data2;

NSString *myString = @"string for data1";

NSString *yourString = @"string for data2";

const char *utfMyString = [myString UTF8String];

const char *utfYourString = [yourString UTF8String];

unsigned char *firstBuffer, secondBuffer[20];

/* initialize data1, data2, and secondBuffer... */

data1 = [NSMutableData dataWithBytes:utfMyString length:strlen(utfMyString)+1];

data2 = [NSMutableData dataWithBytes:utfYourString length:strlen(utfYourString)+1];

[data2 getBytes:secondBuffer];

NSLog(@"data2 before: \"%s\"\n", (char *)secondBuffer);

firstBuffer = [data2 mutableBytes];

[data1 getBytes:firstBuffer];

NSLog(@"data1: \"%s\"\n", (char *)firstBuffer);

[data2 getBytes:secondBuffer];

NSLog(@"data2 after: \"%s\"\n", (char *)secondBuffer);

打算学习AppleScript, Oreilly正好有本中文的书(《AppleScript权威指南(第二版)》)

看介绍不错:
AppleScript_tdg_cvr.jpg
"AppleScript就像一把瑞士军刀,帮助您利用您的苹果机的强大功能并控制整个系统以及运行于其上的应用程序。作者Matt Neuburg用一种前所未有的方式来教授AppleScript,全面而准确地给每个人(从普通的家庭用户到出版业的专业人士和系统管理员)创建脚本的 知识,来让您的苹果机做任何您需要它做的事情。"





Using NSStreams For A TCP Connection Without NSHost

Q: Given that +getStreamsToHost:port:inputStream:outputStream: is not supported on iPhone OS, how can I create NSStreams for a TCP connection to a named host?

A: You can do this by exploiting the toll-free bridge between NSStream and CFStream. UseCFStreamCreatePairWithSocketToHost to create CFStreams to the host, and then cast the resulting CFStreams to NSStreams.


+ (void)getStreamsToHostNamed:(NSString *)hostName 

port:(NSInteger)port 

  inputStream:(NSInputStream **)inputStreamPtr 

outputStream:(NSOutputStream **)outputStreamPtr

{

    CFReadStreamRef     readStream;

    CFWriteStreamRef    writeStream;

    assert(hostName != nil);

    assert( (port > 0) && (port < 65536) );

    assert( (inputStreamPtr != NULL) || (outputStreamPtr != NULL) );

    readStream = NULL;

    writeStream = NULL;

    CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef) hostName, port,((inputStreamPtr  != nil) ? &readStream : NULL),((outputStreamPtr != nil) ? &writeStream : NULL));

    if (inputStreamPtr != NULL) {

        *inputStreamPtr  = [NSMakeCollectable(readStream) autorelease];

    }

    if (outputStreamPtr != NULL) {

        *outputStreamPtr = [NSMakeCollectable(writeStream) autorelease];

    }

}

Reblog this post [with Zemanta]
MacBook:~ yarshure$  afconvert -hf
Audio file and data formats:


    '3gpp' = 3GP Audio (.3gp)
               data_formats: 'aac ' 'samr'
    '3gp2' = 3GPP-2 Audio (.3g2)
               data_formats: 'aac ' 'samr'
    'adts' = AAC ADTS (.aac, .adts)
               data_formats: 'aac ' 'aach'
    'ac-3' = AC3 (.ac3)
               data_formats: 'ac-3'
    'AIFC' = AIFC (.aifc, .aiff, .aif)
               data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw'
                             'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2'
                             'Qclp' 'agsm'
    'AIFF' = AIFF (.aiff, .aif)
               data_formats: I8 BEI16 BEI24 BEI32
    'amrf' = AMR (.amr)
               data_formats: 'samr'
    'caff' = Apple CAF (.caf)
               data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp'
                             'Qclq' 'aac ' 'aach' 'aacl' 'alac' 'alaw'
                             'dvi8' 'ilbc' 'ima4' I8 BEI16 BEI24 BEI32
                             BEF32 BEF64 LEI16 LEI24 LEI32 LEF32 LEF64
                             'ms\x00\x02' 'ms\x00\x11' 'ms\x001' 'samr'
                             'ulaw'
    'm4af' = Apple MPEG-4 Audio (.m4a)
               data_formats: 'aac ' 'aach' 'aacl' 'alac'
    'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)
               data_formats: '.mp1'
    'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)
               data_formats: '.mp2'
    'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)
               data_formats: '.mp3'
    'mp4f' = MPEG-4 Audio (.mp4)
               data_formats: 'aac ' 'aach' 'aacl'
    'NeXT' = NeXT/Sun (.snd, .au)
               data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 'ulaw'
    'Sd2f' = Sound Designer II (.sd2)
               data_formats: I8 BEI16 BEI24 BEI32
    'WAVE' = WAVE (.wav)
               data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
                             'alaw'

Reblog this post [with Zemanta]

Painting to a Transparency Layer

| No Comments | No TrackBacks
trans_code.gif

iFighter 一些数字

| No Comments | No TrackBacks
来源:http://www.cocoachina.com/blog/blog.php?uid=11
iFighter lite:

2009.03.22 Ready for sale
2009.03.29 日本免費遊戲榜第一名, 日本當天下載量: 5008個
2009.03.31 法國免費遊戲榜第一名, 法國當天下載重: 7603個
2009.04.05 美國免費遊戲榜第一名, 美國當天下載重: 50437個
2009.04.10 總下載量超越100萬!
2009.04.14 美國免費遊戲榜第二名, 排名向下滑, 美國當天下載量: 30471個

直到2009.06.10 為止, 總下載量 200萬++.

最多單日下載量: 116,898 個, 日期為 2009.04.05.

iFighter full version:

2009.05.08 Ready for sale
2009.05.09 美國遊戲榜第20名, 美國當天下載重: 2517個
2009.05.10 美國遊戲榜第15名, 美國當天下載重: 4574個
2009.05.11 美國遊戲榜第6名, 美國當天下載重: 4915個
2009.05.12 美國遊戲榜第5名, 美國當天下載重: 5134個
2009.05.13 美國遊戲榜第4名, 美國當天下載重: 4745個
2009.05.15 美國遊戲榜第3名, 美國當天下載重: 4282個
2009.05.17 美國遊戲榜第2名, 美國當天下載重: 6206個
2009.05.19 美國遊戲榜第3名, 美國當天下載重: 4583個
2009.06.06 美國遊戲榜第10名, 跌出top10向下滑, 美國當天下載重: 2182個

最多單日下載量: 11,851 個, 日期為 2009.05.17.

最好成績為美國遊戲類第二名和總類第三名!
dryiceboy_092758170721904.jpg 屏幕快照 2009-10-02 上午12.26.28.png
 iPhone Application Programming CS193P
 视频下载

Debugging With GDB 笔记

| No Comments | No TrackBacks

标准文档 官方手册

GDB需要编译时使用-g 参数
1 (gdb)break main 设置断点
           break  file.m: 36 在file.m处设置断点
   (gdb)info breakpoints 查看断点信息
(gdb) info break
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x0000660c in -[CocoaXMLParser downloadAndParse:] at /Developer/Platforms/iPhoneOS.platform/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone3_0.iPhoneLibrary.docset/Contents/Resources/Documents/samplecode/XMLPerformance/XMLPerformance/Classes/CocoaXMLParser.m:72
    breakpoint already hit 1 time
  (gdb) disable 1 禁止断点1

2 (gdb)run 运行程序
3 (gdb)next 执行下一行代码
4 (gbb)shell cc -g -o memerror merror.m
   不退出gdb编译程序
   (gdb)run blargle 带参数运行程序
5 (gdb) call (int) strlen(argv[1]) 调用func
6 (gdb) set var stringbuffer = (void *) maclloc ((int)strlen(argv[1]+1)
   修改代码,而无须重新编译和重新运行,patch error 当前session立即生效
7 (gdb) list 列出当前代码片段

iPhone UI开发进阶

| No Comments | No TrackBacks
iPhone UI开发进阶 不使用InterFace Builder进行界面设计
  1. 苹果公司2008年3月发布iPhone Beta,Beta1 没有提供InterFace Builder工具,所以早期sample code都是code写出来的。
  2. iPhone SDK Beta2发布,开始支持InterFace Builder。 但是很多代码并没有很快地迁移到InterFace Builder上,还是使用code构建。
  3. UI设计导致无法使用InterFace Builder进行开发
  4. 动画设计需求 
看代码: