存档在 ‘iPhone’ 分类

iPhone压缩与解压缩

2009年12月14日

ziparchive是基于开源代码”MiniZip”的zip压缩与解压的Objective-C 的Class,使用起来非常的简单.你只需要把代码加进你的工程,然后把zlib库添加到工程就可以了.

压缩:

ZipArchive可以压缩多个文件,只需要把文件一一addFileToZip即可.

  1. ZipArchive* zip = [[ZipArchive alloc] init];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *dcoumentpath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
    NSString* l_zipfile = [dcoumentpath stringByAppendingString:@"/test.zip"] ;

    NSString* image1 = [dcoumentpath stringByAppendingString:@"/image1.jpg"] ;
    NSString* image2 = [dcoumentpath stringByAppendingString:@"/image2.jpg"] ;

    BOOL ret = [zip CreateZipFile2:l_zipfile];
    ret = [zip addFileToZip:image1 newname:@"image1.jpg"];
    ret = [zip addFileToZip:image2 newname:@"image2.jpg"];
    if( ![zip CloseZipFile2] )
    {
    l_zipfile = @”";
    }
    [zip release];

解压缩:

  1. ZipArchive* zip = [[ZipArchive alloc] init];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *dcoumentpath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;

    NSString* l_zipfile = [dcoumentpath stringByAppendingString:@"/test.zip"] ;
    NSString* unzipto = [dcoumentpath stringByAppendingString:@"/test"] ;
    if( [zip UnzipOpenFile:l_zipfile] )
    {
    BOOL ret = [zip UnzipFileTo:unzipto overWrite:YES];
    if( NO==ret )
    {
    }
    [zip UnzipCloseFile];
    }
    [zip release];

This article was written in springnote.

创建自定义的iPhone Application Xcode Template

2009年11月23日

本人不喜欢使用interface builder创建界面,因为它会使整个程序不易读,为了方便起见,就修改了一个不使用IB的模板,免得每次都要手动修改,浪费时间.

xcode的模板文件是放在

/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application

我复制了一份View-based Application然后把名字改为View-based Application No IB
然后把*.xib文件全部删除,然后把xxinfo.plist中的Main nib file base name MainWindow
行删除.
然后再把source文件里面通过*.xib文件创建的window和viewcontroller手工创建,然后大功告成.
以后通过xcode的向导就可以创建不使用IB的应用程序了.
下面是我修改的template,可以拷过去用.

[Xcode Template] MobileSubstrate Dylib Template for Xcode

2009年11月23日

来源:

1.把模板copy到
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application
2.从iPhone上获取libsubstrate,然后放到
/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/
3.使用classdump工具把SpringBoard的header文件导出,然后放置到
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include/SpringBoard/

然后使用XCode “New Project”,选择MobileSubstratelib模板,然后编译生成app.然后把app里面的binary后缀改为dylib,然后上传到
iPhone,使用ldid工具去除签名即可.

期待的应用商店

2009年9月7日

appstore的成功引来了nokia,google,中国移动等公司纷纷效仿,他们都能像apple的appstore那样成功吗?我看未必。

作为一个手机软件开发者,我肯定很乐意看到这些软件商店能够成功,这样也可以写点软件游戏赚点小钱。但是一个成功的软件商店有哪些要素呢?我觉得如果一个平台能够吸引大量的开发者为它开发软件,那这样的商店才有可能成功。而什么样的商店才会吸引大量的开发者为它开发软件呢?我以个人开发者的身份的体会归纳了几点。

1.大量手机终端支持

必须有大量的手机终端的支持,只有用户基础大,我们开发的软件才能卖给更多的用户,才能获取更多的收入。这点nokia和中国移动都有优势。

2.开发容易

开放的平台,丰富的API,好的开发工具。这些都能吸引开发者进行开发。iPhone胜在良好的开发环境,开发工具,以及丰富的API。symbian这方面就有些差距,symbian的入门比较难,api也比较别扭,文档不丰富都给开发造成很多的困难。而android的开发使用java,并且android是开源的系统,并且有剽窃自android的移动oms的力推,android的将来也很令人期待。

3.版权保护

没有破解的iPhone只能通过appstore和itunes下载安装软件,有效的保护了开发者的软件不被盗版。而移动的mm平台下载的软件可以随便分享给别人安装,根本无法保护软件版权。nokia ovi store的情况不太清楚。而nokia的签名机制也是令开发者头疼的事情,一般的开发者无法承受200欧元的签名费用,况且每次升级都需要签名。

更多的开发者开发了更多的软件,吸引了更多的用户购买,用户基础扩大,也给开发者提供了更大的市场。所以,目前来看iPhone具备了以上3点,所以获得了很大的成功。

而symbian在中国甚至全球都具有大量的用户,但是它的签名机制以及糟糕的sdk导致了开发者不能快速开发大量的应用软件,所以ovistore不能给用户提供丰富的应用,也就有大的下载量。如果symbian可以改善一下,也许就会有大量的软件被开发出来,放入ovi store。

如何使用makefile文件编译安装app到破解的iPhone

2009年8月28日

翻译转帖自:How-To compile iPhone Project in Mac using Makefile instead of Xcode and fake codesign and then install to pwned iPhone

You can use the command line xcodebuild to build and install iPhone project such as

xcodebuild -target Project_Name
xcodebuild install -target Project_Name

Here is an example to compile iPhone Project using Makefile instead of XCode.

The Makefile will compile and codesign the binary using ldid (Intel binary version) and then install the files directly to iPhone /Applications/ folder using ssh

Location of files
—————-
Classes : source code (.m .c .cpp etc)
Resources : png file and other support files
Project folder : *.xib Info.plist

(1) First you need to download this sample zip file and extract it to your Mac and cd to the directory


curl -O http://www.iphone.org.hk/attach/48150-PeoplePickerDemo.zip
unzip 48150-PeoplePickerDemo.zip
cd PeoplePickerDemo

(3) Change the IPHONE_IP in the Makefile to the IP address of iPhone, default is 10.0.2.2

(4) install respring utility in iPhone
make install_respring

(5) run make and make install
make
make install

(6) Test launch the app Demo in iPhone

In order to avoid typing the password using ssh, you can install the ssh public key of your Mac to your iPhone using the following method

(a) keygen in Mac terminal and type (if you haven’t generated it before)
ssh-keygen -t rsa

You will be asked to enter a passphrase, please remember that if you enter that.

(b) create .ssh directory in iPhone (assume ip address of iPhone is 10.0.2.2) and in Mac terminal and type
ssh root@10.0.2.2 'mkdir -p .ssh'
then enter iPhone root password (alpine)

(c) copy mac public key to iPhone, and in Mac Terminal type
cat ~/.ssh/id_rsa.pub | ssh root@10.0.2.2 'cat >> .ssh/authorized_keys'
then enter iPhone root password (alpine)

(d) Edit the file /etc/ssh/sshd_config in iPhone

change these

#StrictModes yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

to


StrictModes no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

(e)reboot iPhone

To compile ldid in Power PC, do this


wget http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.476.tgz

tar -zxf ldid-1.0.476.tgz

# this patch is for PowerPC only
wget -qO- http://fink.cvs.sourceforge.net/viewvc/*checkout*/fink/dists/10.4/unstable/crypto/finkinfo/ldid.patch?revision=1.1 | patch -p0

cd ldid-1.0.476

g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c

sudo cp -a util/ldid /usr/bin

关于引进iPhone帮联通算个账

2009年8月12日

联通引入iPhone被多次炒作,炒来炒去已经让人生厌,没有了新鲜感。网上很多砖家教授,不知道是受雇佣于移动还是电信,还是因为联通没给他们塞钱,一味的对于引入iPhone拍砖。更有砖家抛出iPhone将会被Ophone替代,真是让人笑掉大牙。iPhone我是很熟的,做为开发者,做为用户,也是用了一年多了。对于Ophone我也见过,不过不是联想那款,而是LG的,我的体验是白给我我也不会去用,具体以后再说。先给联通算算账。

1.如果按传言联通购买500万部iPhone,成本只有2000元的话。即使2500-3000的裸机销售,联通都是稳赚不赔,500w的销量也是很稀松平常,你看看这个价位能买到什么手机就知道。即使成熟如wcdma,也才可以买到E71,黑莓8900,HTC G2,X1,N85等等,TD和evdo基本上没什么可选的。如果有人对联通引进的iPhone没有wifi耿耿于怀的话,其实nokia很多手机行货都没有wifi,但是一样卖的很火。wifi的确很重要,但是绝对不是不可以没有。如果联通能够有比较合适便宜的流量包月,没有wifi的iPhone一样很爽。所以,联通引进iPhone不可能赔本。

2.尽管裸机卖联通也不会赔本,但是显然联通做为运营商肯定不是为了赚这个钱,那么必定会绑定一定的套餐。有了这个套餐,iPhone就可以给联通带来大批的用户。假如联通以3500的价格,绑定每月100的套餐2年或者2500的价格,每月200的套餐2年,还是很有竞争力的。套餐的价格不能直接计入iPhone的成本,你想想,如果你不买联通的iPhone你难道每个月就不会消费200或者100了吗?显然不会影响你的消费的,如果你的消费是低于100的话,你大可以买别人换的iPhone或者水货,相信水货的价格也会大大降低。这样看,引进iPhone不仅不会赔本还会赚钱还会给联通带来用户。

3.如果联通能够获得app store的中国区代理权,那么以后还可以得到和开发者的30%的分成,即使去掉各种测试成本,维护运营成本,还是可以赚一笔钱,当然前提是app store的中国经营权联通能拿到,能够把app store在中国做大做好!

以上分析都是假设,有可能联通的定价更高,套餐更贵,那样的话iPhone可能卖不出去,但是为了不砸手里也会降到一个合理的价格。所以,如果联通充分调查市场的话,价格不会比我预测的高多少。

wcdma的确是个好牌,有很多的终端支持,联通一定不要只把重点放在iPhone上,N97,G2,Hero,idou,….很多的手机体验都很不错,联通都可以以绑定套餐的形式卖给用户,以增加联通的用户。当然,最重要的是把网络建好,服务提高上去,制定切实可行的套餐,只有这样才可以吸引更多的用户加入wcdma阵营,真正的让用户体验到3G。

lepard 10.5.7安装完毕

2009年8月9日

由于10.5.5之后有了笔记本,就一直没有升级系统,用得也很少。正好有个朋友需要10.5.7得安装,就下载了一个ideneb 1.5的10.5.7的系统,顺便自己也刻录了一张。周末下雨,安装了一下。安装很快,可是安装以后无法进入系统,一直黑屏,后来把显卡驱动全部删除掉,进入系统重新安装就ok了。无线网卡也可以工作了。可惜,声卡还是不可以。暂时不折腾了,反正有macbook,也不会常用pc。