Categories
Recent Posts

Archive for October, 2009

iPhone开发中的问题整理(一)

看到很刚开始开发iPhone软件的朋友问很多问题,其实同样的问题我也碰到过, 所以抽时间把能想到的或者碰到的问题汇总一下, 一来可以给自己做个备忘也可以和朋友们分享探讨。

1. iPhone SDK 开发能不能使用C / C++ 语言?

Answer: iPhone SDK的开发的基础框架是基于cocoa库的, Objective-C 是cocoa的开发语言, 但基于Objective-C的特性,在iPhone程序中可以使用C/C++进行功能开发以及使用第三方C/C++库。 Read the rest of this entry »

ZipArchive has been updated to version 1.1 (更新至1.1版)

ZipArchive is a wrapper class to compress and uncompress zip files for Objective-C and cocoa use. It’s developed based on minizip and zlib.  The latest version is 1.1, new feature includes :

✩ create password protected zip files

✩ unzip password protected zip files

To obtain the new version up to date, please visit the project website http://code.google.com/p/ziparchive/

ZipArchive 是基于minizip和zlib的Objective-C 类, 用于创建和解压zip格式的压缩文件, 最新版本为1.1, 新增功能如下:

✩ 创建有密码保护的zip文件

✩ 解压有密码保护的zip文件

为了保证获取最新的版本, 请访问该项目网页 http://code.google.com/p/ziparchive/

iPhone 开发最实用网站

iPhone越来越普及, 从而越来越多的人加入到了iPhone开发的行列, 还记得大概2年前刚开始iPhone SDK开发的时候苦于四处寻找资料, 当时国内相关内容少的可怜, 只有cocoachina 及论坛。 大多数时候泡在apple 官方论坛。 现在不同了, 各类iPhone相关的网站可谓铺天盖地, 其中内容重复的也不在少数, 个人经常上的只有几个, 在此列出共大家参考:

英文站点及论坛:

http://www.cocoadevcentral.com/ 绝对钻石级入门教学网站。 从Object-C到cocoa,再到xcode以及InterfaceBuilder,由浅入深剖析的非常清楚,难得的好网站

http://www.iphonedevsdk.com/forum 一开始就汇聚众多高手的网站,内容大多非常有价值,现在成员多了估计水分变大,但仍然是学习、提问的好地方

http://stackoverflow.com 包括各种语言的技术论坛, 非常有含金量, 很多疑难问题都能在此得到高手的解答

Apple官方论坛 官方论坛, 是个解决问题的好地方:)

中文站点:

cocoachina 几乎每天都去的网站,高手众多,现在潜水严重。

如果其它好的站点, 希望大家分享;)

Create custom checkbox style button for iPhone

Recently, I got a task to develop an application for iPhone. In the application,  there are some optional choices for user to decide further processes. The first idea jumps out from my head is something like button with a checkbox just the same as other desktop platforms, but unfortunately, iPhone SDK doesn’t provide such view. The only official choice is the ON|OFF switch view,  but it really can’t represent the actually meaning of the options. So comes out the idea of writing  custom checkbox style button.

It’s really easy to implement. What we need is two images which are statuses for check and uncheck.  Here are the runtime screenshots:

checkbutton uncheckbutton

The class  for Checkbox button  is CheckButton,  it’s inherited from UIButton,  look at the declaration:

1
2
3
4
5
6
7
8
9
10
#import 
 
@interface CheckButton : UIButton {
	BOOL		_checked;
}
 
@property (nonatomic, setter=setChecked) BOOL checked;
 
-(void) setChecked:(BOOL) check;
@end

Implementation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#import "CheckButton.h"
 
@implementation CheckButton
@synthesize checked = _checked;
 
-(id) init
{
	if( self=[super init] )
	{
		self.checked = NO;
		[self addTarget:self action:@selector(OnCheck:) forControlEvents:UIControlEventTouchUpInside];
	}
	return self;
}
 
-(void) awakeFromNib
{
	self.checked = NO;
	[self addTarget:self action:@selector(OnCheck:) forControlEvents:UIControlEventTouchUpInside];
}
 
-(void) dealloc
{
	[super dealloc];
}
 
-(void) setChecked:(BOOL) check
{
	_checked = check;
	if( _checked )
	{
		UIImage* img = [UIImage imageNamed:@"check.png"];
		[self setImage:img forState:UIControlStateNormal];
	}
	else
	{
		UIImage* img = [UIImage imageNamed:@"uncheck.png"];
		[self setImage:img forState:UIControlStateNormal];
	}
}
 
-(void) OnCheck:(id) sender
{
	self.checked = !_checked;
}
 
@end

To use the class, import the header where contains the button, and declare a IBOutlet with type of “CheckButton”, and connect the IBOutlet in InterfaceBuilder to the member as shown below:
import

This is simple but exactly meet my requirement. Of course, someone wants to include title text of the button within the button class,  it’s sure to be easy to do :)

Here is the sample project zip file.

全VB代码生成小说, 牛

近日 , 由网友编写的VB程序自动生成的小说 《宇宙巨校闪级生》正式上线, 该小说长达一亿七千万字,文本字节容量高达340 MB, 全部共111部,分1111卷, 同时创下无数个“最”。 以下是一段作者的自述:

本书是用VB语言编写的魔幻神侠小说,适合所有年龄段的读者阅读。本书共有111部,分为1111卷,按纯文本(txt格式)计算,本书的总字数超过340兆,如换成中文计算:总字数应该不会少于一亿七千万字。这次公开的是本书中的前二十部,后面的九十一部及未来的升级版、简化版和第一人称版《蘑菇王子传》将在找到理想的合作者之后再陆续推出。由于本书的写作过程是全自动完成,所以本书至少创造了五个世界之最。。。

有兴趣的可以看一下http://html.hjsm.tom.com/html/new_book/29/421/d82f1776b0abe00ba37f5d27b3c6.html

升级到 iDeneb 10.5.8,并解决xcode调试断点问题

Snow Leopard正式版已经发布有一段时间了,看了一下iHackintosh的介绍,升级到Snow Leopard需要一块新的硬盘,作罢。 今天抽空将iDeneb系统升级到10.5.8, 升级过程非常简单,如果已经是10.5.7系统就下载官方更新包Delta update(274MB), 如果是低版本则下载Combo update(759MB)。 在升级之前,还需要下载osx86tools

在升级之前还需要注意的是备份kext驱动程序, 每次改动之前都做备份是个很好的习惯。 然后按照下面的步骤进行升级,

1. 下载并安装 Disabler.kext (如果是用osx86tools安装,切记不要重新启动)

2. 下载并安装 dsmos.kext

3. 重新启动系统

4. 备份所有的kext, 以便出错后恢复

sudo cp -rf /System/Library/Extensions /System/Library/Extensions_old

5. 打开下载的官方升级程序, 成功后会看到安装成功,是否重新启动的页面,此时不要重新启动,直接进行下一步

6. 运行 osx86tools, 勾选Check repair permissions , Set kext permissions , Clear extensions cache 三项, 然后点击“Run selected tasks”,安装结束会提示重新启动,如果没重启就自己重启系统

在启动时输入参数 -v 查看出错信息,如果一切正常则升级成功。

关于xcode调试时断点不停的问题, 新的voodoo内核虽然解决了断点问题, 但是不能进行step over 和step in等详细调试操作, 网上有人说在启动时输入启动参数: std_dyld=1,我试过但没有用, 做好发现输入参数还需要添加几项,正确的参数应该为:

busratio=20 cpus=1 std_dyld=1

这样在xcode中调试时,断点就可以正常工作了, 而且可以进行step over 等调试操作