<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6245963027152906987</id><updated>2012-02-02T11:58:41.874+08:00</updated><category term='class-dump'/><category term='p2p bluetooth'/><category term='Codesign error'/><category term='Xcode'/><category term='toolchain 2.0'/><category term='Inline Assembler'/><category term='Calendar'/><category term='javacom'/><category term='ARM'/><category term='iPhone GCC'/><category term='Cycript'/><category term='iPhone OS 3.0'/><category term='UIAccelerometer'/><category term='Local Notification'/><category term='ipagod'/><category term='iPhone OS 4.0'/><category term='Makefile'/><category term='mobilesubstrate'/><category term='Virtual PC 2007'/><category term='theos'/><category term='git'/><category term='OpenGL ES'/><category term='weak linking'/><category term='XCode 4 Template'/><category term='hardware info'/><category term='Settings'/><category term='iTunes Connect Mobile'/><category term='ldid'/><category term='Drag and Drop'/><category term='cydia'/><category term='iAd'/><category term='Emoji'/><category term='Sample Code'/><category term='Email Signature'/><category term='Tethering'/><category term='SMS'/><category term='odcctools'/><category term='cocos2d'/><category term='iPhone SDK'/><category term='Provisioning Profile'/><category term='Decrypted IPA'/><category term='Google Wave'/><category term='Touch Fighter'/><category term='toolchain'/><category term='iCloud'/><category term='MMS'/><category term='Android SDK'/><category term='SDK'/><category term='iPhone OS 2.2.1 and 3.0 compatible'/><category term='Thank you'/><category term='iPhone'/><category term='UIKit'/><category term='re-codesign'/><category term='Push Notification Service'/><category term='Ubuntu'/><category term='Foundation Framework'/><category term='iPad'/><category term='SmartScreen Widget'/><category term='Objective C 2.0'/><category term='MFMessageComposeViewController'/><category term='subversion'/><title type='text'>iPhone Software Development</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>78</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3065749056848836390</id><published>2012-01-30T23:56:00.007+08:00</published><updated>2012-02-02T11:58:41.892+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='odcctools'/><title type='text'>Darwin CC Tools odcctools_782-1_iphoneos-arm.deb</title><content type='html'>Darwin CC Tools,  linker and assembler for the iOS.&lt;br /&gt;v782 update&lt;br /&gt;Supports armv6 and armv7&lt;br /&gt;&lt;br /&gt;Download here http://apiexplorer.googlecode.com/files/odcctools_782-1_iphoneos-arm.deb&lt;br /&gt;Instruction to build, see here http://github.com/javacom/toolchain4&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The last build was v286 and released in 2008&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3065749056848836390?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3065749056848836390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3065749056848836390' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3065749056848836390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3065749056848836390'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2012/01/darwin-cc-tools-odcctools782-1iphoneos.html' title='Darwin CC Tools odcctools_782-1_iphoneos-arm.deb'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-1782917410780653215</id><published>2011-10-30T15:30:00.073+08:00</published><updated>2012-01-02T14:59:52.780+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='theos'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone GCC'/><title type='text'>How to install perl, theos and iphone-gcc in iPhone</title><content type='html'>(1) Install the following packages in Cydia&lt;br /&gt;APT 0.6 Transitional (and all its dependencies)&lt;br /&gt;wget&lt;br /&gt;&lt;br /&gt;(2) Use SSH login shell commands to install perl &amp; theos (or install them in Cydia by adding Sources)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;echo "deb http://coredev.nl/cydia iphone main" &gt; /etc/apt/sources.list.d/coredev.nl.list&lt;br /&gt;wget http://coredev.nl/cydia/coredev.pub&lt;br /&gt;apt-key add coredev.pub&lt;br /&gt;apt-get update&lt;br /&gt;apt-get install perl&lt;br /&gt;echo "deb http://nix.howett.net/theos ./" &gt; /etc/apt/sources.list.d/howett.net.list&lt;br /&gt;apt-get update&lt;br /&gt;apt-get install net.howett.theos  rsync&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you have No space left on device error when installing perl , relocate /usr/local to /var/stash/local&lt;br /&gt;&lt;br /&gt;(3) Use SSH login shell commands to install iphone-gcc and ldid (or install them in Cydia)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;wget http://apt.saurik.com/debs/libgcc_4.2-20080410-1-6_iphoneos-arm.deb &lt;br /&gt;dpkg -i libgcc_4.2-20080410-1-6_iphoneos-arm.deb &lt;br /&gt;apt-get update&lt;br /&gt;apt-get install iphone-gcc &lt;br /&gt;apt-get install make ldid zip unzip com.ericasadun.utilities&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) Download SDK3.2 Headers and Libs from &lt;a href="http://www.2shared.com/file/5pueVAUR/iPhoneSDKHeadersAndLibs_32.html"&gt;here&lt;/a&gt; &lt;br /&gt;Please take note that the current iPhone-gcc does not support iOS SDK 4.0 or above&lt;br /&gt;&lt;br /&gt;(5) copy iPhoneSDKHeadersAndLibs_32.pkg to iPhone&lt;br /&gt;&lt;br /&gt;(6) Install SDK and additional libraries to sdk&lt;br /&gt;&lt;code&gt;&lt;br /&gt;apt-get update&lt;br /&gt;apt-get install xar cpio&lt;br /&gt;xar -xf iPhoneSDKHeadersAndLibs_32.pkg Payload&lt;br /&gt;cat Payload | zcat | cpio -id&lt;br /&gt;mv Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk /var/sdk&lt;br /&gt;cd /var/sdk/usr/lib/&lt;br /&gt;ln -s libstdc++.6.dylib libstdc++.dylib&lt;br /&gt;ln -s crt1.o crt1.10.5.o&lt;br /&gt;ln -s dylib1.o dylib1.10.5.o&lt;br /&gt;cp -p /usr/lib/libgcc_s.10.5.dylib .&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(7) Create a command line tool project&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/var/theos/bin/nic.pl helloworld&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(8) Choose [4.] iphone/tool&lt;br /&gt;&lt;br /&gt;(9) Edit main.mm and add printf and cout like this&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;main.mm  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;using namespace std;&lt;br /&gt;int main(int argc, char **argv, char **envp) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Hello World\n");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout &amp;lt;&amp;lt; "Hello CPP" &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(10) Add the ADDITIONAL_CFLAGS and ADDITIONAL_CPPFLAGS in Makefile like this&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile (Tool)  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;export THEOS=/var/theos&lt;br /&gt;include $(THEOS)/makefiles/common.mk&lt;br /&gt;&lt;br /&gt;TOOL_NAME = helloworld&lt;br /&gt;helloworld_FILES = main.mm&lt;br /&gt;&lt;br /&gt;ADDITIONAL_CFLAGS = -I"$(SYSROOT)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include"&lt;br /&gt;ADDITIONAL_CPPFLAGS = -I"$(SYSROOT)/usr/include/c++/4.2.1"&lt;br /&gt;ADDITIONAL_CPPFLAGS += -I"$(SYSROOT)/usr/include/c++/4.2.1/armv6-apple-darwin10" &lt;br /&gt;&lt;br /&gt;include $(THEOS_MAKE_PATH)/tool.mk&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(11) Make and test run&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd helloworld&lt;br /&gt;make clean&lt;br /&gt;make&lt;br /&gt;./obj/helloworld&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(12) For app, the sample Makefile is&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile (Application)  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;export THEOS=/var/theos&lt;br /&gt;include $(THEOS)/makefiles/common.mk&lt;br /&gt;&lt;br /&gt;APPLICATION_NAME = myapp&lt;br /&gt;myapp_FILES = main.m&lt;br /&gt;myapp_FILES += $(wildcard Classes/*.m)&lt;br /&gt;&lt;br /&gt;myapp_FRAMEWORKS = UIKit&lt;br /&gt;&lt;br /&gt;PCH:=$(wildcard *.pch)&lt;br /&gt;&lt;br /&gt;ADDITIONAL_CFLAGS = -I"$(SYSROOT)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include"&lt;br /&gt;ADDITIONAL_CPPFLAGS = -I"$(SYSROOT)/usr/include/c++/4.2.1"&lt;br /&gt;ADDITIONAL_CPPFLAGS += -I"$(SYSROOT)/usr/include/c++/4.2.1/armv6-apple-darwin10" &lt;br /&gt;ifneq ($(PCH),)&lt;br /&gt;ADDITIONAL_CFLAGS += -include $(PCH)&lt;br /&gt;ADDITIONAL_CPPFLAGS += -include $(PCH)&lt;br /&gt;endif&lt;br /&gt;&lt;br /&gt;include $(THEOS_MAKE_PATH)/application.mk&lt;br /&gt;&lt;br /&gt;RESOURCESFOLDER=./Resources&lt;br /&gt;PAYLOADFOLDER=$(THEOS_STAGING_DIR)&lt;br /&gt;OBJFOLDER=./obj&lt;br /&gt;INFOPLIST:=$(wildcard *Info.plist)&lt;br /&gt;INFOPLIST+=$(wildcard Resources/*Info.plist)&lt;br /&gt;PNGFILES:=$(wildcard Resources/*.png)&lt;br /&gt;LPROJFILES:=$(wildcard Resources/*.lproj)&lt;br /&gt;APPVERSION=$(shell plutil -key CFBundleVersion $(INFOPLIST) 2&gt;&amp;1)&lt;br /&gt;&lt;br /&gt;# make ipa&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;ipa:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;stage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rm -fr $(PAYLOADFOLDER)/* $(APPLICATION_NAME)_$(APPVERSION).ipa&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rm -f Payload&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mkdir -p $(PAYLOADFOLDER)/$(APPLICATION_NAME).app&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp $(OBJFOLDER)/$(APPLICATION_NAME) $(PAYLOADFOLDER)/$(APPLICATION_NAME).app/.&lt;br /&gt;ifneq ($(PNGFILES),)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp -rp $(RESOURCESFOLDER)/*.png $(PAYLOADFOLDER)/$(APPLICATION_NAME).app/.&lt;br /&gt;endif&lt;br /&gt;ifneq ($(LPROJFILES),)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp -rp $(RESOURCESFOLDER)/*.lproj $(PAYLOADFOLDER)/$(APPLICATION_NAME).app/.&lt;br /&gt;endif&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@echo "APPL????" &gt; $(PAYLOADFOLDER)/$(APPLICATION_NAME).app/PkgInfo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp -p $(INFOPLIST) $(PAYLOADFOLDER)/$(APPLICATION_NAME).app/.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ln -sf $(PAYLOADFOLDER) Payload&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zip -r $(APPLICATION_NAME)_$(APPVERSION).ipa Payload &gt; /dev/null&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(13) For mobilesubstrate extension, the sample Makefile is&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile (Tweak)  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;export THEOS=/var/theos&lt;br /&gt;include $(THEOS)/makefiles/common.mk&lt;br /&gt;&lt;br /&gt;TWEAK_NAME = mytweak&lt;br /&gt;APP_ID = com.mycompany.mytweak&lt;br /&gt;mytweak_FILES = Tweak.xm&lt;br /&gt;mytweak_FRAMEWORKS = UIKit&lt;br /&gt;&lt;br /&gt;ADDITIONAL_CFLAGS = -I"$(SYSROOT)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include"&lt;br /&gt;ADDITIONAL_CPPFLAGS = -I"$(SYSROOT)/usr/include/c++/4.2.1"&lt;br /&gt;ADDITIONAL_CPPFLAGS += -I"$(SYSROOT)/usr/include/c++/4.2.1/armv6-apple-darwin10"&lt;br /&gt;&lt;br /&gt;include $(THEOS_MAKE_PATH)/tweak.mk&lt;br /&gt;&lt;br /&gt;# make package&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;after-stage::&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;find $(THEOS_STAGING_DIR) -iname '*.plist' -exec plutil -convert binary1 {} \;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(FAKEROOT) chown -R 0:80 $(THEOS_STAGING_DIR)&lt;br /&gt;&lt;br /&gt;PACKAGEFOLDER=./layout&lt;br /&gt;CONTROLFILE=control&lt;br /&gt;PACKAGENAME=$(shell grep ^Package: $(CONTROLFILE) | cut -d ' ' -f 2)&lt;br /&gt;PACKAGEVERSION=$(shell grep ^Version: $(CONTROLFILE) | cut -d ' ' -f 2)&lt;br /&gt;ARCH=$(shell grep ^Architecture: $(CONTROLFILE) | cut -d ' ' -f 2)&lt;br /&gt;OBJFOLDER=./obj&lt;br /&gt;_EXCLUDES ?= tmp _MTN .git .svn .DS_Store ._*&lt;br /&gt;_EXCLUDE_COMMANDLINE := $(foreach exclude,$(_EXCLUDES),--exclude "$(exclude)")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# with dpkg-deb&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;deb: stage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rm -fr $(PACKAGENAME)_$(PACKAGEVERSION)_$(ARCH).deb $(PACKAGEFOLDER)/control.tar.gz $(PACKAGEFOLDER)/data.tar.gz $(PACKAGEFOLDER)/tmp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mkdir -p $(PACKAGEFOLDER)/Library/MobileSubstrate/DynamicLibraries/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mkdir -p $(PACKAGEFOLDER)/DEBIAN&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp $(OBJFOLDER)/$(TWEAK_NAME).dylib $(PACKAGEFOLDER)/Library/MobileSubstrate/DynamicLibraries/.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp $(CONTROLFILE) $(PACKAGEFOLDER)/DEBIAN/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dpkg-deb -b $(PACKAGEFOLDER) $(PACKAGENAME)_$(PACKAGEVERSION)_$(ARCH).deb&lt;br /&gt;&lt;br /&gt;# without dpkg-deb&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;deb2: stage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mkdir -p $(PACKAGEFOLDER)/Library/MobileSubstrate/DynamicLibraries/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mkdir -p $(PACKAGEFOLDER)/DEBIAN&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp $(CONTROLFILE) $(PACKAGEFOLDER)/DEBIAN/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rm -f $(PACKAGENAME)_$(PACKAGEVERSION)_$(ARCH).deb $(PACKAGEFOLDER)/control.tar.gz $(PACKAGEFOLDER)/data.tar.gz&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rm -f $(PACKAGEFOLDER)/tmp/*.gz&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mkdir -p $(PACKAGEFOLDER)/tmp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo "2.0" &gt; $(PACKAGEFOLDER)/tmp/debian-binary&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp $(OBJFOLDER)/$(TWEAK_NAME).dylib $(PACKAGEFOLDER)/Library/MobileSubstrate/DynamicLibraries/.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cd $(PACKAGEFOLDER)/DEBIAN; tar -czf ../tmp/control.tar.gz ./&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cd $(PACKAGEFOLDER); tar -czf ./tmp/data.tar.gz $(_EXCLUDE_COMMANDLINE) ./&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cd $(PACKAGEFOLDER)/tmp;  ar -rv ../../$(PACKAGENAME)_$(PACKAGEVERSION)_$(ARCH).deb ./debian-binary ./control.tar.gz ./data.tar.gz&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rm -fr $(PACKAGEFOLDER)/tmp/*.gz&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;For mobilesubstrate extension, download the iPhone headers from http://github.com/rpetrich/iphoneheaders/archives/master&lt;br /&gt;&lt;br /&gt;and place the frameworks at top level (i.e. SpringBoard folder copy to /var/theos/include/SpringBoard).&lt;br /&gt;libsubstrate.dylib is also needed in /var/theos/lib folder&lt;br /&gt;&lt;br /&gt;Note: perl is needed for creating project folder and compiling mobilesubstrate extension,  if you only develop app and command line tool, you could remove perl by using &lt;br /&gt;&lt;code&gt;&lt;br /&gt;apt-get remove perl&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(14) This is how to combine Tweak and Settings Bundle in a project&lt;br /&gt;/var/theos/bin/nic.pl MyTweak&lt;br /&gt;and choose [5.] iphone/tweak&lt;br /&gt;/var/theos/bin/nic.pl MyTweakSettings&lt;br /&gt;and choose [3.] iphone/preference_bundle&lt;br /&gt;mv mytweaksettings/*.mm mytweaksettings/Resources mytweaksettings/entry.plist mytweak/&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile (Tweak + Bundle)  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;export THEOS=/var/theos&lt;br /&gt;export GO_EASY_ON_ME=1&lt;br /&gt;include $(THEOS)/makefiles/common.mk&lt;br /&gt;&lt;br /&gt;TWEAK_NAME = MyTweak&lt;br /&gt;#MyTweak_FILES = MyTweak.xm&lt;br /&gt;MyTweak_FRAMEWORKS = UIKit&lt;br /&gt;&lt;br /&gt;BUNDLE_NAME = MyTweakSettings&lt;br /&gt;MyTweakSettings_FILES = MyTweakSettings.mm&lt;br /&gt;MyTweakSettings_INSTALL_PATH = /System/Library/PreferenceBundles&lt;br /&gt;MyTweakSettings_FRAMEWORKS = UIKit&lt;br /&gt;MyTweakSettings_PRIVATE_FRAMEWORKS = Preferences&lt;br /&gt;&lt;br /&gt;ADDITIONAL_CFLAGS = -I"$(SYSROOT)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include"&lt;br /&gt;ADDITIONAL_CPPFLAGS = -I"$(SYSROOT)/usr/include/c++/4.2.1"&lt;br /&gt;ADDITIONAL_CPPFLAGS += -I"$(SYSROOT)/usr/include/c++/4.2.1/armv6-apple-darwin10"&lt;br /&gt;&lt;br /&gt;include $(THEOS_MAKE_PATH)/tweak.mk&lt;br /&gt;include $(THEOS_MAKE_PATH)/bundle.mk&lt;br /&gt;include $(THEOS_MAKE_PATH)/aggregate.mk&lt;br /&gt;&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;internal-stage::&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(BUNDLE_NAME).plist$(ECHO_END)&lt;br /&gt;&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;after-stage::&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;find $(THEOS_STAGING_DIR) -iname '*.plist' -exec plutil -convert binary1 {} \;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(FAKEROOT) chown -R 0:80 $(THEOS_STAGING_DIR)&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(15) If you want to test the iOS5 Notification Center Widget&lt;br /&gt;get it from http://github.com/WillFour20/WeeAppTest&lt;br /&gt;&lt;br /&gt;&lt;code&gt;git clone git://github.com/WillFour20/WeeAppTest.git&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and modified with the following Makefile&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile (nc Tweak)  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;export THEOS=/var/theos&lt;br /&gt;SDKVERSION = 5.0&lt;br /&gt;include $(THEOS)/makefiles/common.mk&lt;br /&gt;&lt;br /&gt;BUNDLE_NAME = WeeAppTest &lt;br /&gt;WeeAppTest_FILES = WeeAppTest.mm&lt;br /&gt;WeeAppTest_INSTALL_PATH = /System/Library/WeeAppPlugins/&lt;br /&gt;WeeAppTest_FRAMEWORKS = UIKit CoreGraphics&lt;br /&gt;#WeeAppTest_PRIVATE_FRAMEWORKS = BulletinBoard&lt;br /&gt;&lt;br /&gt;ADDITIONAL_CFLAGS = -I"$(SYSROOT)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include"&lt;br /&gt;ADDITIONAL_CPPFLAGS = -I"$(SYSROOT)/usr/include/c++/4.2.1"&lt;br /&gt;ADDITIONAL_CPPFLAGS += -I"$(SYSROOT)/usr/include/c++/4.2.1/armv6-apple-darwin10"&lt;br /&gt;&lt;br /&gt;include $(THEOS_MAKE_PATH)/bundle.mk&lt;br /&gt;&lt;br /&gt;# replace 4 spaces with TAB for below&lt;br /&gt;after-install::&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;install.exec "killall -9 SpringBoard"&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;and &lt;code&gt;make clean package install&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(15) where is IOSurfaceAPI.h in Lion&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Here&lt;br /&gt;/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-1782917410780653215?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/1782917410780653215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=1782917410780653215' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1782917410780653215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1782917410780653215'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2011/10/how-to-install-perl-theos-and-iphone.html' title='How to install perl, theos and iphone-gcc in iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-8441082562079371852</id><published>2011-06-11T14:18:00.028+08:00</published><updated>2011-06-12T19:56:41.711+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='iCloud'/><title type='text'>iCloud App Sample and entitlement code-sign error</title><content type='html'>iOS 5 beta has iCloud support now, but getting the entitlement code-sign to work has some steps that are missing from Apple Documentation.&lt;br /&gt;&lt;br /&gt;You should use the new Xcode 4.2 for iOS 5 SDK and with iOS5 on an iDevice.&lt;br /&gt;&lt;br /&gt;1) You need to create a new App ID in the iOS Provisional Portal, if you use an existing ID, it must not be a wildcard one.  For example, you create a new APP ID called &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;com.yourcompany.icloudtest&lt;/span&gt;  and the App Name is called &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;icloudtest&lt;/span&gt;&lt;br /&gt;When you create the New App ID, you will be asked whether to Generate New or select an existing one for the Prefix (existing prefix can have the benefit of sharing the same keychain access or may be iCloud Document folder).  Suppose we generate a new prefix in this case.  And the new generated prefix is 99Z9Z98987&lt;br /&gt;&lt;br /&gt;2) After created the New App ID, you should first enable iCloud for that New App ID and then create the a New Provisional Profile for that New App &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;icloudtest&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;3)  Suppose the new Development Profile called "iCloudTest" is created and downloaded to the Mac.&lt;br /&gt;&lt;br /&gt;4) Launch Xcode and created an empty Universal Application called "icloudtest" and the Bundle Identifier should be &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;com.yourcompany.icloudtest&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/-Yt1eR69IUoo/TfMVldd57tI/AAAAAAAABV4/VpLuJ883Jy8/s1600/icloudtest1.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 347px;" src="http://4.bp.blogspot.com/-Yt1eR69IUoo/TfMVldd57tI/AAAAAAAABV4/VpLuJ883Jy8/s400/icloudtest1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5616856893570543314" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;5) Import the Development Profile "iCloudTest.mobileprovision" to Xcode and to iPhone/iPad which should be iOS 5 beta&lt;br /&gt;&lt;br /&gt;6) Click the Build Settings of the Project and Select the code sign identity to the "iCloudTest" Provisional Profile&lt;br /&gt;&lt;br /&gt;7) Click the Summary Settings of the Project and scroll down to entitlements and click the Custom Entitlements, Xcode will create a file called icloudtest.entitlements&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/-YVbsmpmGzJI/TfMXjWxWYpI/AAAAAAAABWQ/hPyvTX7lw5k/s1600/icloudtest4.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 324px;" src="http://1.bp.blogspot.com/-YVbsmpmGzJI/TfMXjWxWYpI/AAAAAAAABWQ/hPyvTX7lw5k/s400/icloudtest4.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5616859056436568722" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;8) Click the icloudtest.entitlements in the Project Explorer and add these key rows (Right Click -&amp;gt; Add Row) in the entitlements file&lt;br /&gt;com.apple.developer.ubiquity-kvstore-identifier is String Type&lt;br /&gt;com.apple.developer.ubiquity-container-identifiers is Array Type&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/-cZRiDKTOnOE/TfMV1o7w1VI/AAAAAAAABWA/SIaG62QkXIM/s1600/icloudtest2.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 128px;" src="http://4.bp.blogspot.com/-cZRiDKTOnOE/TfMV1o7w1VI/AAAAAAAABWA/SIaG62QkXIM/s400/icloudtest2.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5616857171526473042" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;9) Enter the &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;Team-ID&lt;/span&gt;.com.yourcompany.icloudtest into the Value column.  The important part is where to get the Team-ID ?&lt;br /&gt;&lt;br /&gt;10) Don't confuse with the Team-ID with the App ID that the development portal generated for you.  If you look at the "iCloudTest.mobileprovision" file downloaded as in step 5 above.  You will see something like this&lt;br /&gt;&lt;br /&gt;Yes, &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;ZZZZ826ZZ2&lt;/span&gt; is the &lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;Team-ID&lt;/span&gt; where 99Z9Z989Z7 is the App ID in this case&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;  iCloudTest.mobileprovision  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=8441082562079371852#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;key&amp;gt;Entitlements&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;lt;dict&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;application-identifier&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;99Z9Z989Z7.com.yourcompany.icloudtest&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;com.apple.developer.ubiquity-container-identifiers&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;array&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;&lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;ZZZZ826ZZ2&lt;/span&gt;.*&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;/array&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;com.apple.developer.ubiquity-kvstore-identifier&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;&lt;span class="Apple-style-span"  style="color:#ff0000;"&gt;ZZZZ826ZZ2&lt;/span&gt;.*&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;get-task-allow&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;true/&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;keychain-access-groups&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;array&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;99Z9Z989Z7.*&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;/array&amp;gt;&lt;br /&gt;&amp;lt;/dict&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Team-ID can also be found at Your Account area of Member Center&lt;br /&gt;After login the iOS Dev Center, click&lt;br /&gt;Member Center (in top navigation bar)-&gt; Your Account -&gt; Program Membership -&gt; Individual ID&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-J5RzAYKG7sg/TfM7v-sQiMI/AAAAAAAABWg/cCCHDy277Bg/s1600/icloudtest6.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 176px;" src="http://1.bp.blogspot.com/-J5RzAYKG7sg/TfM7v-sQiMI/AAAAAAAABWg/cCCHDy277Bg/s400/icloudtest6.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5616898855729662146" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;11) Enter the Team-ID + Bundle Identifier in the icloudtest.entitlements as below&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/-uxFpCCBLEIQ/TfMWmLUpMgI/AAAAAAAABWI/TsCume3N-TM/s1600/icloudtest3.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 70px;" src="http://3.bp.blogspot.com/-uxFpCCBLEIQ/TfMWmLUpMgI/AAAAAAAABWI/TsCume3N-TM/s400/icloudtest3.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5616858005391356418" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;  icloudtest.entitlements  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=8441082562079371852#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!--?xml version="1.0" encoding="UTF-8"?--&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;plist version="1.0"&amp;gt;&lt;br /&gt;&amp;lt;dict&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;com.apple.developer.ubiquity-kvstore-identifier&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;ZZZZ826ZZ2.com.yourcompany.icloudtest&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;com.apple.developer.ubiquity-container-identifiers&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;array&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;ZZZZ826ZZ2.com.yourcompany.icloudtest&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;/array&amp;gt;&lt;br /&gt;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;lt;/plist&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;12) Add these code in the icloudtestAppDelegate.m to test this iCloud App&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;  icloudtestAppDelegate.m  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=8441082562079371852#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions&lt;br /&gt;{&lt;br /&gt;  // Override point for customization after application launch.&lt;br /&gt;  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];&lt;br /&gt;&lt;br /&gt;  NSFileManager *fileManager = [NSFileManager defaultManager];&lt;br /&gt;  // Team-ID + Bundle Identifier&lt;br /&gt;  NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:@"ZZZZ826ZZ2.com.yourcompany.icloudtest"];&lt;br /&gt;  NSLog(@"%@", [iCloudURL absoluteString]);&lt;br /&gt;&lt;br /&gt;  NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore defaultStore];&lt;br /&gt;  [cloudStore setString:[iCloudURL absoluteString] forKey:@"iCloudURL"];&lt;br /&gt;  [cloudStore synchronize]; // Important as it stores the values you set before on iCloud&lt;br /&gt;&lt;br /&gt;  UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,round(self.window.bounds.size.height/4.0),self.window.bounds.size.width,round(self.window.bounds.size.height/8.0))];&lt;br /&gt;  myLabel.font = [UIFont fontWithName:@"Marker Felt" size:round(self.window.bounds.size.width/20.0)];&lt;br /&gt;  myLabel.numberOfLines = 4;&lt;br /&gt;  myLabel.text =[ @"iCloudURL=" stringByAppendingFormat:@"%@", [cloudStore stringForKey:@"iCloudURL"]];&lt;br /&gt;  myLabel.backgroundColor = [UIColor clearColor];&lt;br /&gt;  myLabel.textColor = [UIColor whiteColor];&lt;br /&gt;  myLabel.textAlignment = UITextAlignmentCenter;&lt;br /&gt;  [self.window addSubview:myLabel];&lt;br /&gt;&lt;br /&gt;  [self.window makeKeyAndVisible];&lt;br /&gt;  return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;13) Run it in iOS device&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-8441082562079371852?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/8441082562079371852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=8441082562079371852' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8441082562079371852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8441082562079371852'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2011/06/icloud-app-sample-and-entitlement-code.html' title='iCloud App Sample and entitlement code-sign error'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-Yt1eR69IUoo/TfMVldd57tI/AAAAAAAABV4/VpLuJ883Jy8/s72-c/icloudtest1.png' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-8427633975983010381</id><published>2011-05-02T21:05:00.029+08:00</published><updated>2011-05-03T15:19:48.397+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XCode 4 Template'/><title type='text'>XCode 4 Template</title><content type='html'>The new Xcode 4 cannot use the old  Xcode 3 templates.  There are a few changes&lt;br /&gt;&lt;br /&gt;1.  Template folder location &lt;br /&gt;/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates&lt;br /&gt;/Users/&amp;lt;username&amp;gt;/Library/Developer/Xcode/Templates/&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mkdir -p ~/Library/Developer/Xcode/Templates&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2.  The Templates are in folders like&lt;br /&gt;&lt;br /&gt;iPad Base.xctemplate, iPhone Base.xctemplate, Cocoa Touch Application.xctemplate&lt;br /&gt;View-based Application.xctemplate Window-based Application.xctemplate&lt;br /&gt;&lt;br /&gt;3. The Ancestors, Definitions and Options are defined in TemplateInfo.plist&lt;br /&gt;&lt;br /&gt;4. To add files in the Template, you should define them in Definitions like&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Definitions&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;___PACKAGENAMEASIDENTIFIER___MyController.h&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Group&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;My Classes&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Path&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;Classes/___PACKAGENAMEASIDENTIFIER___MyController.h&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;___PACKAGENAMEASIDENTIFIER___MyController.m&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&gt;Group&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;My Classes&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Path&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;Classes/___PACKAGENAMEASIDENTIFIER___MyController.m&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;README&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Path&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;README&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;lt;!--       excluded in targets        --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;TargetIndices&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;array/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;lt;!--       Other definitions here        --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Also define in Nodes&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Nodes&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;array&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;___PACKAGENAMEASIDENTIFIER___MyController.h&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;___PACKAGENAMEASIDENTIFIER___MyController.m&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;README&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;lt;!--       Other nodes here        --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/array&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;5.  To add build stage for existing Target&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Targets&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;array&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;BuildPhases&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;array&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Class&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;ShellScript&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;ShellPath&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;/bin/bash&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;ShellScript&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;ls -l&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/array&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;lt;!--       Other targets here        --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/array&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;6.  Add New Target&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Targets&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;array&amp;gt;&lt;br /&gt;&amp;lt;!--       Default target here        --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Name&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;My Target for ___PACKAGENAME___&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;TargetType&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;Aggregate&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;SharedSettings&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;PRODUCT_NAME&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;$(TARGET_NAME)&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;BuildPhases&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;array&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;Class&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;ShellScript&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;ShellPath&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;/bin/bash&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;ShellScript&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;ls -l&amp;lt;/string&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/array&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/array&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;For ShellScript, please use html codes like these&lt;br /&gt;&lt;br /&gt;&lt;TABLE WIDTH="200" ALIGN="LEFT" border=1&gt;&lt;br /&gt;&lt;tr&gt;&lt;td align=center&gt;&amp;amp;lt;    &lt;/td&gt;&lt;td align=center&gt;      &amp;lt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td align=center&gt;&amp;amp;gt;    &lt;/td&gt;&lt;td align=center&gt;     &amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td align=center&gt;&amp;amp;amp;  &lt;/td&gt;&lt;td align=center&gt;  &amp;amp;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-8427633975983010381?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/8427633975983010381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=8427633975983010381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8427633975983010381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8427633975983010381'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2011/05/xcode-4-template.html' title='XCode 4 Template'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-6675923143020960590</id><published>2011-05-01T12:23:00.001+08:00</published><updated>2011-05-01T12:25:31.946+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ipagod'/><title type='text'>ipagod on iPad2</title><content type='html'>&lt;div class="snap_preview"&gt;&lt;p&gt;&lt;span style="text-align:center; display: block;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="350"&gt; &lt;param value="http://www.youtube.com/watch?v=BvzPpB5Euwc" name="movie" /&gt;  &lt;embed width="425" src="http://www.youtube.com/watch?v=BvzPpB5Euwc" height="350" type="application/x-shockwave-flash"&gt; &lt;/embed&gt; &lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-6675923143020960590?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/6675923143020960590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=6675923143020960590' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6675923143020960590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6675923143020960590'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2011/05/ipagod-on-ipad2.html' title='ipagod on iPad2'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-5471313653636196663</id><published>2011-04-18T12:29:00.001+08:00</published><updated>2011-04-18T12:30:50.499+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='git'/><title type='text'>My GitHub</title><content type='html'>My GitHub&lt;br /&gt;&lt;br /&gt;http://github.com/javacom&lt;br /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-5471313653636196663?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/5471313653636196663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=5471313653636196663' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5471313653636196663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5471313653636196663'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2011/04/my-github.html' title='My GitHub'/><author><name>javacom</name><uri>http://www.blogger.com/profile/10745838995139328314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7631335789485793052</id><published>2010-09-03T17:30:00.021+08:00</published><updated>2010-09-03T18:24:24.259+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='Calendar'/><title type='text'>How to calculate Easter Day in iPhone OS</title><content type='html'>Recently, I have to implement the calculation of Easter Day.&lt;br /&gt;&lt;br /&gt;Here is what I got&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;Easter Day is always the Sunday after the full moon that occurs after the spring equinox on March 21.&lt;/span&gt; This full moon may happen on any date between March 21 and April 18 inclusive. If the full moon falls on a Sunday, Easter Day if the Sunday following. But Easter Day cannot be earlier than March 22 or later than April 25.&lt;br /&gt;&lt;br /&gt;To find the the full moon day, I have used the NSChineseCalendar in iOS 4.&lt;br /&gt;&lt;br /&gt;and my implementation is here&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;  eastercal.m  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=7631335789485793052#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;// eastercal.m&lt;br /&gt;#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main( int argc, char *argv[] )&lt;br /&gt;{&lt;br /&gt;   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;   NSDate *today = [NSDate date];     // today&lt;br /&gt;   NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];&lt;br /&gt;   NSUInteger unitFlags = NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit;&lt;br /&gt;   NSDateComponents *gregorianComps = [gregorian components:unitFlags fromDate:today];&lt;br /&gt;   if (argc==2) {&lt;br /&gt;     [gregorianComps setYear:atoi(argv[1])];&lt;br /&gt;   }&lt;br /&gt;   [gregorianComps  setDay:21];&lt;br /&gt;   [gregorianComps setMonth:3];&lt;br /&gt;   NSDate *easterStartDate = [gregorian dateFromComponents:gregorianComps]; //March 21 for the year&lt;br /&gt;&lt;br /&gt;   NSCalendar *chinese = [[NSCalendar alloc] initWithCalendarIdentifier:NSChineseCalendar];&lt;br /&gt;   // convert from gregorian calendar to chinese calendar&lt;br /&gt;   NSDateComponents *chineseComps = [chinese components:unitFlags fromDate:easterStartDate];&lt;br /&gt;   NSDate *easterStartDateChineseDate = [chinese dateFromComponents:chineseComps];&lt;br /&gt;&lt;br /&gt;   NSDate *easterStartDateChineseDateTemp = easterStartDateChineseDate;&lt;br /&gt;   if ([chineseComps day] &gt;=15) {            // 15 is the full month day in Chinese Calendar&lt;br /&gt;      NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];&lt;br /&gt;      [offsetComponents setMonth:1];                   // set the next month&lt;br /&gt;      easterStartDateChineseDateTemp = [chinese dateByAddingComponents:offsetComponents toDate:easterStartDateChineseDate options:0];&lt;br /&gt;   }&lt;br /&gt;   NSDateComponents *dayComponents = [chinese components:NSDayCalendarUnit fromDate:easterStartDateChineseDateTemp];&lt;br /&gt;   NSDateComponents *componentsToAdd = [[NSDateComponents alloc] init];&lt;br /&gt;   [componentsToAdd setDay: (15 - [dayComponents day])];&lt;br /&gt;   // find the next full month date&lt;br /&gt;   NSDate *springEquinoChineseDate = [chinese dateByAddingComponents:componentsToAdd toDate:easterStartDateChineseDateTemp options:0];&lt;br /&gt;&lt;br /&gt;   NSDateComponents *springEquinoChineseComps = [chinese components:unitFlags fromDate:springEquinoChineseDate];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   NSDateComponents *diffComps = [chinese components:NSDayCalendarUnit fromDate:easterStartDateChineseDate toDate:springEquinoChineseDate options:0];&lt;br /&gt;   NSInteger diffDays = [diffComps day];&lt;br /&gt;&lt;br /&gt;   // calculate the days difference from the March 21 to the next full month day&lt;br /&gt;   NSLog(@"diffDays is %ld",diffDays);&lt;br /&gt;&lt;br /&gt;   NSDateComponents *daysToAdd = [[NSDateComponents alloc] init];&lt;br /&gt;   [daysToAdd setDay:diffDays];&lt;br /&gt;   NSDate *springEquinoGregorianDate = [gregorian dateByAddingComponents:daysToAdd toDate:easterStartDate options:0];&lt;br /&gt;&lt;br /&gt;   // convert the next full month date from ChineseDate to GregorianComps&lt;br /&gt;   NSDateComponents *springEquinoGregorianComps = [gregorian components:unitFlags fromDate:springEquinoGregorianDate];&lt;br /&gt;&lt;br /&gt;   NSLog(@"springEquinoGregorian is %ld %ld %ld",[springEquinoGregorianComps year], [springEquinoGregorianComps month], [springEquinoGregorianComps day]);&lt;br /&gt;&lt;br /&gt;   int weekday = [springEquinoGregorianComps weekday];&lt;br /&gt;   NSDate *easterSundayGregorianDateTemp = springEquinoGregorianDate;&lt;br /&gt;   NSDateComponents *offsetGregorianComponents = [[NSDateComponents alloc] init];&lt;br /&gt;   if (weekday == 7) {&lt;br /&gt;      [offsetGregorianComponents setWeek:2]; // If the full moon falls on a Sunday, Easter Day if the Sunday following&lt;br /&gt;   }&lt;br /&gt;   else {&lt;br /&gt;      [offsetGregorianComponents setWeek:1];&lt;br /&gt;   }&lt;br /&gt;    easterSundayGregorianDateTemp = [gregorian dateByAddingComponents:offsetGregorianComponents toDate:springEquinoGregorianDate options:0];&lt;br /&gt;   NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:easterSundayGregorianDateTemp];&lt;br /&gt;   NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init];&lt;br /&gt;   [componentsToSubtract setDay: 0 - ([weekdayComponents weekday] - 1)];&lt;br /&gt;   NSDate *easterDate = [gregorian dateByAddingComponents:componentsToSubtract toDate:easterSundayGregorianDateTemp options:0];&lt;br /&gt;&lt;br /&gt;   NSDateComponents *easterComps = [gregorian components:unitFlags fromDate:easterDate];&lt;br /&gt;   NSLog(@"Easter Date is %d %d %d",[easterComps year], [easterComps month], [easterComps day]);&lt;br /&gt;   [pool drain];&lt;br /&gt;   return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;This code does not run on Mac OS 10.5 or iOS 3 as the ChineseCalendar was not implemented.&lt;br /&gt;It will only run on Mac OS 10.6 or iOS 4&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;iPhone-4:root# gcc -I/var/toolchain/sys30/usr/include -F/var/toolchain/sys30/System/Library/Frameworks -L/var/toolchain/sys30/usr/lib -framework Foundation eastercal.m -o eastercal&lt;br /&gt;iPhone-4:root# ldid -S eastercal&lt;br /&gt;iPhone-4:root# ./eastercal 2011&lt;br /&gt;eastercal[3005:107] diffDays is 27&lt;br /&gt;eastercal[3005:107] springEquinoGregorian is 2011 4 17&lt;br /&gt;eastercal[3005:107] Easter Date is 2011 4 24&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7631335789485793052?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7631335789485793052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7631335789485793052' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7631335789485793052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7631335789485793052'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/09/how-to-calculate-easter-day-for-iphone.html' title='How to calculate Easter Day in iPhone OS'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-5611919145579968254</id><published>2010-06-25T04:25:00.003+08:00</published><updated>2010-06-25T04:29:54.633+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iTunes Connect Mobile'/><title type='text'>iTunes Connect Mobile AppStore Link</title><content type='html'>&lt;a href="http://itunes.apple.com/us/app/itunes-connect-mobile/id376771144?mt=8"&gt;http://itunes.apple.com/us/app/itunes-connect-mobile/id376771144?mt=8&lt;/a&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r1000/022/Purple/93/ed/ba/mzi.orfwclam.100x100-75.jpg'/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r5120/022/Purple/93/ed/ba/mzi.orfwclam.512x512-75.jpg'/&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r1000/057/Purple/c2/1c/73/mzl.miogxzas.480x480-75.jpg'/&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r1000/010/Purple/4d/e7/19/mzl.zxotgwrj.480x480-75.jpg'/&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r1000/002/Purple/94/c1/03/mzl.skrwklrl.480x480-75.jpg'/&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r1000/047/Purple/58/1f/53/mzl.brtftpgf.480x480-75.jpg'/&gt;&lt;br /&gt;&lt;img src='http://a1.phobos.apple.com/us/r1000/028/Purple/5e/74/c2/mzl.ckbrywnf.480x480-75.jpg'/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-5611919145579968254?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/5611919145579968254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=5611919145579968254' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5611919145579968254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5611919145579968254'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/06/itunes-connect-mobile-appstore-link.html' title='iTunes Connect Mobile AppStore Link'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-6037453011287907597</id><published>2010-06-16T08:55:00.004+08:00</published><updated>2010-06-18T10:27:57.000+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cydia'/><title type='text'>iphone.org.hk/apt/ is down</title><content type='html'>Please update the cydia source url&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;&lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;http://cydia.iphone.org.hk/apt/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3LRNVfBfliQ/TBrZf9FtOxI/AAAAAAAAAz4/LB2GdwbCGZE/s1600/serverdown.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 300px; height: 317px;" src="http://1.bp.blogspot.com/_3LRNVfBfliQ/TBrZf9FtOxI/AAAAAAAAAz4/LB2GdwbCGZE/s400/serverdown.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5483934639274670866" /&gt;&lt;/a&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-6037453011287907597?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/6037453011287907597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=6037453011287907597' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6037453011287907597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6037453011287907597'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/06/iphoneorghkapt-is-down.html' title='iphone.org.hk/apt/ is down'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_3LRNVfBfliQ/TBrZf9FtOxI/AAAAAAAAAz4/LB2GdwbCGZE/s72-c/serverdown.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2150975608114143557</id><published>2010-06-08T22:35:00.002+08:00</published><updated>2010-06-08T22:40:40.492+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iAd'/><title type='text'>Sign up for iAd</title><content type='html'>Here in iTunes Connect -&gt; Contracts&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/TA5VjC9i-0I/AAAAAAAAAzo/fj8KtB4U_cs/s1600/iad.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 224px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/TA5VjC9i-0I/AAAAAAAAAzo/fj8KtB4U_cs/s400/iad.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5480411857135270722" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2150975608114143557?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2150975608114143557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2150975608114143557' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2150975608114143557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2150975608114143557'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/06/sign-up-for-iad.html' title='Sign up for iAd'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/TA5VjC9i-0I/AAAAAAAAAzo/fj8KtB4U_cs/s72-c/iad.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3265179793473042296</id><published>2010-06-07T23:17:00.009+08:00</published><updated>2010-06-08T07:46:09.647+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPad'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone GCC'/><title type='text'>iPhone gcc for SDK 3.2 &amp; iPad</title><content type='html'>iPhone gcc for SDK 3.2&lt;br /&gt;(1) Install iphone gcc installed in your jailbroken iPad with firmware 3.2&lt;br /&gt;&lt;br /&gt;iPhone gcc is available in Cydia.  To install it in you need to do these&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# assume you have installed &lt;span style="font-style:italic;"&gt;APT 0.6 Transitional&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;Aptitude&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;wget&lt;/span&gt; in Cydia, so that you can use the command apt-get&lt;br /&gt;# if libgcc is broken in Cydia, you have to install it manually before iphone-gcc&lt;br /&gt;wget http://apt.saurik.com/debs/libgcc_4.2-20080410-1-6_iphoneos-arm.deb &lt;br /&gt;dpkg -i libgcc_4.2-20080410-1-6_iphoneos-arm.deb &lt;br /&gt;# install iphone-gcc&lt;br /&gt;apt-get install iphone-gcc &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Moreover, install these utilities via apt-get as well&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;apt-get install make ldid zip unzip wget&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;for editor in iPad you could use &lt;span style="font-style:italic;"&gt;vim&lt;/span&gt; or &lt;span style="font-style:italic;"&gt;nano&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(2) Header files for toolchain and SDK 3.2&lt;br /&gt;&lt;br /&gt;the header files for SDK 3.2 is available in one zipped tar file (sys32.tgz).  You can download it (about 147M) &lt;a href="http://www.2shared.com/file/wx3Kc7RW/sys32.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(3) copy and untar the required headers and libraries (first copy to /var/mobile/sys32.tgz) and install it in iPad say&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mkdir -p /var/toolchain/&lt;br /&gt;cd /var/toolchain/&lt;br /&gt;tar -xzvf /var/mobile/sys32.tgz&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) Use this sample TabBarSample.zip and unzip it to test.&lt;br /&gt;&lt;br /&gt;This TabBar sample source code is compatible with iPad and iPhone gcc, with auto-rotation and auto-resizing support.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://apiexplorer.googlecode.com/files/TabBarSample.zip"&gt;http://apiexplorer.googlecode.com/files/TabBarSample.zip&lt;/a&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;wget http://apiexplorer.googlecode.com/files/TabBarSample.zip&lt;br /&gt;unzip TabBarSample.zip&lt;br /&gt;cd TabBarSample&lt;br /&gt;make install&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/TA2BTUePxdI/AAAAAAAAAzg/zl-mCaKm0r8/s1600/tabbarsample.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 300px; height: 400px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/TA2BTUePxdI/AAAAAAAAAzg/zl-mCaKm0r8/s400/tabbarsample.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5480178490492831186" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The package includes a new command line utility called appinstall, it is used to install compiled app to /var/mobile/Applications/*  directory for iPad, it simulates the app install process via XCode.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3265179793473042296?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3265179793473042296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3265179793473042296' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3265179793473042296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3265179793473042296'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/06/iphone-gcc-for-sdk-32-ipad.html' title='iPhone gcc for SDK 3.2 &amp; iPad'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_3LRNVfBfliQ/TA2BTUePxdI/AAAAAAAAAzg/zl-mCaKm0r8/s72-c/tabbarsample.png' height='72' width='72'/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2116978344453470198</id><published>2010-04-18T19:37:00.014+08:00</published><updated>2010-04-24T23:09:02.249+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SMS'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 4.0'/><category scheme='http://www.blogger.com/atom/ns#' term='MFMessageComposeViewController'/><title type='text'>MFMessageComposeViewController Sample Code (OS 4.0 only)</title><content type='html'>Start a new View-based Application Project called SMS2&lt;br /&gt;and have to add the MessageUI framework to the project&lt;br /&gt;&lt;br /&gt;Modify SMS2ViewController.h&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;&amp;nbsp;&amp;nbsp;SMS2ViewController.h&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;//  SMS2ViewController.h&lt;br /&gt;//  SMS2&lt;br /&gt;&lt;br /&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;#import &amp;lt;MessageUI/MessageUI.h&amp;gt;&lt;br /&gt;#import &amp;lt;MessageUI/MFMessageComposeViewController.h&amp;gt;&lt;br /&gt;&lt;br /&gt;@interface SMS2ViewController : UIViewController &amp;lt;MFMessageComposeViewControllerDelegate&amp;gt; {&lt;br /&gt; UILabel *message;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) UILabel *message;&lt;br /&gt;&lt;br /&gt;-(void)displayComposerSheet;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;and in SMS2ViewController.m&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;&amp;nbsp;&amp;nbsp;SMS2ViewController.m&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;//  SMS2ViewController.m&lt;br /&gt;//  SMS2&lt;br /&gt;&lt;br /&gt;#import "SMS2ViewController.h"&lt;br /&gt;&lt;br /&gt;@implementation SMS2ViewController&lt;br /&gt;@synthesize message;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;// The designated initializer. Override to perform setup that is required before the view is loaded.&lt;br /&gt;- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {&lt;br /&gt;    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {&lt;br /&gt;        // Custom initialization&lt;br /&gt;    }&lt;br /&gt;    return self;&lt;br /&gt;}&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Implement loadView to create a view hierarchy programmatically, without using a nib.&lt;br /&gt;/*&lt;br /&gt; - (void)loadView {&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.&lt;br /&gt;- (void)viewDidLoad {&lt;br /&gt;       [super viewDidLoad];&lt;br /&gt;       UIButton *smsButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];&lt;br /&gt;       smsButton.frame = CGRectMake(97.0, 301.0, 125.0, 37.0);&lt;br /&gt;       smsButton.adjustsImageWhenDisabled = YES;&lt;br /&gt;&lt;br /&gt;       [smsButton setTitle:@" Send SMS" forState:UIControlStateNormal];&lt;br /&gt;       [smsButton setTitleColor:[UIColor colorWithWhite:0.000 alpha:1.000] forState:UIControlStateNormal];&lt;br /&gt;       [smsButton setTitleShadowColor:[UIColor colorWithWhite:0.000 alpha:1.000] forState:UIControlStateNormal]; &lt;br /&gt;       [smsButton addTarget:self action:@selector(displayComposerSheet) forControlEvents:UIControlEventTouchUpInside];&lt;br /&gt; &lt;br /&gt;       message = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 360.0, 280.0, 29.0)];&lt;br /&gt;       message.frame = CGRectMake(20.0, 360.0, 280.0, 29.0);&lt;br /&gt;       message.adjustsFontSizeToFitWidth = YES;&lt;br /&gt;       message.hidden = YES;&lt;br /&gt;       message.text = @"";&lt;br /&gt;       message.userInteractionEnabled = NO;&lt;br /&gt;&lt;br /&gt;       [self.view addSubview:smsButton];  &lt;br /&gt;       [self.view addSubview:message];  &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-(void)displayComposerSheet &lt;br /&gt;{&lt;br /&gt;       MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];&lt;br /&gt;       picker.messageComposeDelegate = self;&lt;br /&gt; &lt;br /&gt;       picker.recipients = [NSArray arrayWithObject:@"123456789"];   // your recipient number or self for testing&lt;br /&gt;       picker.body = @"test from OS4";&lt;br /&gt; &lt;br /&gt;       [self presentModalViewController:picker animated:YES];&lt;br /&gt;       [picker release];&lt;br /&gt;       NSLog(@"SMS fired");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {&lt;br /&gt;       message.hidden = NO;&lt;br /&gt;       switch (result)&lt;br /&gt;       {&lt;br /&gt;       case MessageComposeResultCancelled:&lt;br /&gt;         message.text = @"Result: canceled";&lt;br /&gt;         NSLog(@"Result: canceled");&lt;br /&gt;         break;&lt;br /&gt;       case MessageComposeResultSent:&lt;br /&gt;         message.text = @"Result: sent";&lt;br /&gt;         NSLog(@"Result: sent");&lt;br /&gt;         break;&lt;br /&gt;       case MessageComposeResultFailed:&lt;br /&gt;         message.text = @"Result: failed";&lt;br /&gt;         NSLog(@"Result: failed");&lt;br /&gt;         break;&lt;br /&gt;       default:&lt;br /&gt;         message.text = @"Result: not sent";&lt;br /&gt;         NSLog(@"Result: not sent");&lt;br /&gt;         break;&lt;br /&gt;       }&lt;br /&gt; &lt;br /&gt;       [self dismissModalViewControllerAnimated:YES];&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Override to allow orientations other than the default portrait orientation.&lt;br /&gt;- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {&lt;br /&gt;    return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)didReceiveMemoryWarning {&lt;br /&gt; // Releases the view if it doesn't have a superview.&lt;br /&gt;    [super didReceiveMemoryWarning];&lt;br /&gt; &lt;br /&gt; // Release any cached data, images, etc that aren't in use.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)viewDidUnload {&lt;br /&gt; // Release any retained subviews of the main view.&lt;br /&gt; // e.g. self.myOutlet = nil;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)dealloc {&lt;br /&gt;    [super dealloc];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/S8rxlK1-CsI/AAAAAAAAAy4/TlVZycFwsA8/s1600/smsos4.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 267px; height: 400px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/S8rxlK1-CsI/AAAAAAAAAy4/TlVZycFwsA8/s400/smsos4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5461443119008320194" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2116978344453470198?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2116978344453470198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2116978344453470198' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2116978344453470198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2116978344453470198'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/04/mfmessagecomposeviewcontroller-sample.html' title='MFMessageComposeViewController Sample Code (OS 4.0 only)'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/S8rxlK1-CsI/AAAAAAAAAy4/TlVZycFwsA8/s72-c/smsos4.png' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3158200416120145199</id><published>2010-04-17T10:43:00.008+08:00</published><updated>2010-04-18T12:27:50.673+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 4.0'/><title type='text'>Enable Homescreen Wallpaper in iPhone Simulator OS 4.0 beta 1</title><content type='html'>Edit this file (you need root access&lt;br /&gt;&lt;br /&gt;/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/CoreServices/SpringBoard.app/simulator.plist&lt;br /&gt;&lt;br /&gt;and add the key as below&lt;br /&gt;"homescreen-wallpaper" = 1;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/S8kg42nxeLI/AAAAAAAAAyw/SGDIjRhDOKY/s1600/simhomescreen.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 341px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/S8kg42nxeLI/AAAAAAAAAyw/SGDIjRhDOKY/s400/simhomescreen.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5460932184270534834" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The default HomeBackground.jpg and LockBackground.jpg are here&lt;br /&gt;/Users/&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); "&gt;yourusername&lt;/span&gt;/Library/Application Support/iPhone Simulator/4.0/Library/SpringBoard/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As a bonus, if you add this homescreen-wallpaper key-pair, the problem of "iPhone simulator goes black when trying to taking app to background" problem will be solved. &lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3158200416120145199?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3158200416120145199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3158200416120145199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3158200416120145199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3158200416120145199'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/04/enable-homescreen-wallpaper-in-iphone.html' title='Enable Homescreen Wallpaper in iPhone Simulator OS 4.0 beta 1'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_3LRNVfBfliQ/S8kg42nxeLI/AAAAAAAAAyw/SGDIjRhDOKY/s72-c/simhomescreen.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2429530419471369325</id><published>2010-04-11T10:50:00.010+08:00</published><updated>2010-04-11T11:07:05.844+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 4.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Emoji'/><title type='text'>Enable Emoji Keyboard in iPhone Simulator OS 4.0 beta</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/S8E8yVtZ5KI/AAAAAAAAAyo/CswT0pVBocs/s1600/emoji40.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 231px; height: 400px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/S8E8yVtZ5KI/AAAAAAAAAyo/CswT0pVBocs/s400/emoji40.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5458711058868462754" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;iPhone Simulator can enable Emoji in the new iPhone SDK 4.0 beta (similar to previous releases) in here&lt;br /&gt;&lt;br /&gt;/Users/&lt;span style="color:#FF0000;"&gt;yourusername&lt;/span&gt;/Library/Application\ Support/iPhone\ Simulator/4.0/Library/Preferences/com.apple.Preferences.plist&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/46870-emoji-embed.png"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://itunes.apple.com/app/touch-dial-emoji/id286534260?mt=8" TARGET="_blank"&gt;&lt;img src="http://www.iphone.org.hk/attach/46521-touchdialappstore.png"&gt;&lt;/a&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2429530419471369325?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2429530419471369325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2429530419471369325' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2429530419471369325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2429530419471369325'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/04/enable-emoji-keyboard-in-iphone.html' title='Enable Emoji Keyboard in iPhone Simulator OS 4.0 beta'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_3LRNVfBfliQ/S8E8yVtZ5KI/AAAAAAAAAyo/CswT0pVBocs/s72-c/emoji40.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7733424376588802160</id><published>2010-04-10T12:56:00.018+08:00</published><updated>2011-04-22T07:51:55.544+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 4.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Local Notification'/><title type='text'>Local Notification Sample Code (OS 4.0 only)</title><content type='html'>Start a new Window-based Application Project called LocalPush&lt;br /&gt;&lt;br /&gt;Add an instance variable bgTask in LocalPushAppDelegate&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@interface LocalPushAppDelegate : NSObject &lt;UIApplicationDelegate&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UIWindow *window;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UIBackgroundTaskIdentifier bgTask;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;It will fire up a Local Notification to remind you one min before the event which is 2 minutes due from now &lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; LocalPushAppDelegate.m  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;//&lt;br /&gt;//  LocalPushAppDelegate.m&lt;br /&gt;//  LocalPush&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;@interface ToDoItem : NSObject  {&lt;br /&gt; NSInteger year;&lt;br /&gt; NSInteger month;&lt;br /&gt; NSInteger day;&lt;br /&gt; NSInteger hour;&lt;br /&gt; NSInteger minute;&lt;br /&gt; NSInteger second;&lt;br /&gt; NSString *eventName;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property (nonatomic, readwrite) NSInteger year;&lt;br /&gt;@property (nonatomic, readwrite) NSInteger month;&lt;br /&gt;@property (nonatomic, readwrite) NSInteger day;&lt;br /&gt;@property (nonatomic, readwrite) NSInteger hour;&lt;br /&gt;@property (nonatomic, readwrite) NSInteger minute;&lt;br /&gt;@property (nonatomic, readwrite) NSInteger second;&lt;br /&gt;@property (nonatomic, copy) NSString *eventName;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;@implementation ToDoItem&lt;br /&gt;&lt;br /&gt;@synthesize year, month, day, hour, minute, second, eventName;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;#import "LocalPushAppDelegate.h"&lt;br /&gt;&lt;br /&gt;@implementation LocalPushAppDelegate&lt;br /&gt;&lt;br /&gt;@synthesize window;&lt;br /&gt;&lt;br /&gt;#define ToDoItemKey @"EVENTKEY1"&lt;br /&gt;#define MessageTitleKey @"MSGKEY1"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    &lt;br /&gt; NSLog(@"application: didFinishLaunchingWithOptions:");&lt;br /&gt;    // Override point for customization after application launch&lt;br /&gt; &lt;br /&gt; UILocalNotification *localNotif = [launchOptions&lt;br /&gt;            objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; &lt;br /&gt; &lt;br /&gt; if (localNotif) {&lt;br /&gt;  NSString *itemName = [localNotif.userInfo objectForKey:ToDoItemKey]; &lt;br /&gt;  //  [viewController displayItem:itemName]; // custom method &lt;br /&gt;  application.applicationIconBadgeNumber = localNotif.applicationIconBadgeNumber-1; &lt;br /&gt;  NSLog(@"has localNotif %@",itemName);&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  [[UIApplication sharedApplication] cancelAllLocalNotifications];&lt;br /&gt;  NSDate *now = [NSDate date];&lt;br /&gt;  NSLog(@"now is %@",now);&lt;br /&gt;  NSDate *scheduled = [now dateByAddingTimeInterval:120] ; //get x minute after&lt;br /&gt;  NSCalendar *calendar = [NSCalendar currentCalendar];&lt;br /&gt;&lt;br /&gt;  unsigned int unitFlags = NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit;&lt;br /&gt;  NSDateComponents *comp = [calendar components:unitFlags fromDate:scheduled];&lt;br /&gt;  &lt;br /&gt;  NSLog(@"scheduled is %@",scheduled);&lt;br /&gt;  &lt;br /&gt;  ToDoItem *todoitem = [[ToDoItem alloc] init];&lt;br /&gt;  &lt;br /&gt;  todoitem.day = [comp day];&lt;br /&gt;  todoitem.month = [comp month];&lt;br /&gt;  todoitem.year = [comp year];&lt;br /&gt;  todoitem.hour = [comp hour];&lt;br /&gt;  todoitem.minute = [comp minute];&lt;br /&gt;  todoitem.eventName = @"Testing Event";&lt;br /&gt;  &lt;br /&gt;  [self scheduleNotificationWithItem:todoitem interval:1];&lt;br /&gt;  NSLog(@"scheduleNotificationWithItem");&lt;br /&gt; }&lt;br /&gt; [window makeKeyAndVisible];&lt;br /&gt; return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notif {&lt;br /&gt;   NSLog(@"application: didReceiveLocalNotification:");&lt;br /&gt; NSString *itemName = [notif.userInfo objectForKey:ToDoItemKey];&lt;br /&gt; NSString *messageTitle = [notif.userInfo objectForKey:MessageTitleKey];&lt;br /&gt;// [viewController displayItem:itemName]; // custom method &lt;br /&gt; [self _showAlert:itemName withTitle:messageTitle];&lt;br /&gt; NSLog(@"Receive Local Notification while the app is still running...");&lt;br /&gt; NSLog(@"current notification is %@",notif);&lt;br /&gt; application.applicationIconBadgeNumber = notif.applicationIconBadgeNumber-1; &lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void) _showAlert:(NSString*)pushmessage withTitle:(NSString*)title&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt; UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:pushmessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];&lt;br /&gt; [alertView show];&lt;br /&gt; if (alertView) { &lt;br /&gt;  [alertView release]; &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)scheduleNotificationWithItem:(ToDoItem *)item interval:(int)minutesBefore {&lt;br /&gt;    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];&lt;br /&gt;    NSDateComponents *dateComps = [[NSDateComponents alloc] init];&lt;br /&gt;    [dateComps setDay:item.day];&lt;br /&gt;    [dateComps setMonth:item.month];&lt;br /&gt;    [dateComps setYear:item.year];&lt;br /&gt;    [dateComps setHour:item.hour];&lt;br /&gt;    [dateComps setMinute:item.minute];&lt;br /&gt;    NSDate *itemDate = [calendar dateFromComponents:dateComps];&lt;br /&gt;    [dateComps release];&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    UILocalNotification *localNotif = [[UILocalNotification alloc] init];&lt;br /&gt;    if (localNotif == nil)&lt;br /&gt;        return;&lt;br /&gt;    localNotif.fireDate = [itemDate dateByAddingTimeInterval:-(minutesBefore*60)];&lt;br /&gt;  NSLog(@"fireDate is %@",localNotif.fireDate);&lt;br /&gt;    localNotif.timeZone = [NSTimeZone defaultTimeZone];&lt;br /&gt; &lt;br /&gt;    localNotif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"%@ in %i minutes.", nil),&lt;br /&gt;       item.eventName, minutesBefore];&lt;br /&gt;    localNotif.alertAction = NSLocalizedString(@"View Details", nil);&lt;br /&gt; &lt;br /&gt;    localNotif.soundName = UILocalNotificationDefaultSoundName;&lt;br /&gt;    localNotif.applicationIconBadgeNumber = 1;&lt;br /&gt;//  NSDictionary *infoDict = [NSDictionary dictionaryWithObject:item.eventName forKey:ToDoItemKey];&lt;br /&gt;  NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:item.eventName,ToDoItemKey, @"Local Push received while running", MessageTitleKey, nil];&lt;br /&gt;    localNotif.userInfo = infoDict;&lt;br /&gt; &lt;br /&gt;    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];&lt;br /&gt;  NSLog(@"scheduledLocalNotifications are %@", [[UIApplication sharedApplication] scheduledLocalNotifications]);&lt;br /&gt;    [localNotif release];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (NSString *) checkForIncomingChat {&lt;br /&gt; return @"javacom";&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;- (void)applicationDidEnterBackground:(UIApplication *)application {&lt;br /&gt;    NSLog(@"Application entered background state.");&lt;br /&gt;    // UIBackgroundTaskIdentifier bgTask is instance variable&lt;br /&gt;    // UIInvalidBackgroundTask has been renamed to UIBackgroundTaskInvalid&lt;br /&gt;    NSAssert(self-&gt;bgTask == UIBackgroundTaskInvalid, nil);&lt;br /&gt;&lt;br /&gt;    bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{&lt;br /&gt;        dispatch_async(dispatch_get_main_queue(), ^{&lt;br /&gt;            [application endBackgroundTask:self-&gt;bgTask];&lt;br /&gt;            self-&gt;bgTask = UIBackgroundTaskInvalid;&lt;br /&gt;        });&lt;br /&gt;    }];&lt;br /&gt; &lt;br /&gt;    dispatch_async(dispatch_get_main_queue(), ^{&lt;br /&gt;        while ([application backgroundTimeRemaining] &gt; 1.0) {&lt;br /&gt;            NSString *friend = [self checkForIncomingChat];&lt;br /&gt;            if (friend) {&lt;br /&gt;                UILocalNotification *localNotif = [[UILocalNotification alloc] init];&lt;br /&gt;                if (localNotif) {&lt;br /&gt;                    localNotif.alertBody = [NSString stringWithFormat:&lt;br /&gt;           NSLocalizedString(@"%@ has a message for you.", nil), friend];&lt;br /&gt;                    localNotif.alertAction = NSLocalizedString(@"Read Msg", nil);&lt;br /&gt;                    localNotif.soundName = @"alarmsound.caf";&lt;br /&gt;                    localNotif.applicationIconBadgeNumber = 1;&lt;br /&gt;      NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Your Background Task works",ToDoItemKey, @"Message from javacom", MessageTitleKey, nil];&lt;br /&gt;      localNotif.userInfo = infoDict;&lt;br /&gt;                    [application presentLocalNotificationNow:localNotif];&lt;br /&gt;                    [localNotif release];&lt;br /&gt;                    friend = nil;&lt;br /&gt;                    break;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        [application endBackgroundTask:self-&gt;bgTask];&lt;br /&gt;        self-&gt;bgTask = UIBackgroundTaskInvalid;&lt;br /&gt;    });&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;- (void)dealloc {&lt;br /&gt;    [window release];&lt;br /&gt;    [super dealloc];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/S8AHQoK1O5I/AAAAAAAAAyg/_2FE5t0QfGg/s1600/localpush.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 231px; height: 400px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/S8AHQoK1O5I/AAAAAAAAAyg/_2FE5t0QfGg/s400/localpush.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5458370730615192466" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7733424376588802160?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7733424376588802160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7733424376588802160' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7733424376588802160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7733424376588802160'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/04/local-push-notification-sample-code-os.html' title='Local Notification Sample Code (OS 4.0 only)'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_3LRNVfBfliQ/S8AHQoK1O5I/AAAAAAAAAyg/_2FE5t0QfGg/s72-c/localpush.png' height='72' width='72'/><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2643975082763653111</id><published>2010-04-06T21:01:00.040+08:00</published><updated>2011-12-03T08:25:18.333+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><title type='text'>Old versions of iPhone SDK</title><content type='html'>&lt;u&gt;You need Apple developer account to login&lt;/u&gt;&lt;br /&gt;But Apple has disabled some of the links recently&lt;br /&gt;&lt;br /&gt;iPhone SDK 2.2.1 Leopard (10.5.4)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_for_iphone_os_2.2.1__9m2621a__final/iphone_sdk_for_iphone_os_2.2.19m2621afinal.dmg&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.0 (Xcode 3.1.3) Leopard (10.5.7)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.0__final/iphone_sdk_3.0__leopard__9m2736__final.dmg&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.0 (Xcode 3.2) &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.0)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.0__final/iphone_sdk_3.0__snow_leopard__final.dmg&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.1 with Xcode 3.1.4 Leopard (10.5.7)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1__final/iphone_sdk_3.1_with_xcode_3.1_final__leopard__9m2809.dmg&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.1 with XCode 3.2.1 for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.0)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1__final/iphone_sdk_3.1_with_xcode_3.2_final__snow_leopard__10a432.dmg&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.1.2 with XCode 3.1.4 for Leopard (10.5.7)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1.2__final/iphone_sdk_3.1.2_with_xcode_3.1.4__leopard__9m2809.dmg&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.1.2 with XCode 3.2.1 for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.0)&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1.2__final/iphone_sdk_3.1.2_with_xcode_3.2.1__snow_leopard__10m2003.dmg&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br /&gt;Update : You are too late, Apple has removed the links above.&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iPhone SDK 3.1.3 with XCode 3.1.4 for Leopard (10.5.7)&lt;/span&gt;&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/iphone/iphone_sdk_3.1.3__final/iphone_sdk_3.1.3_with_xcode_3.1.4__leopard__9m2809a.dmg&lt;br /&gt;&lt;br /&gt;iPhone SDK 3.1.3 with XCode 3.2.1 for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.0)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/iphone/iphone_sdk_3.1.3__final/iphone_sdk_3.1.3_with_xcode_3.2.1__snow_leopard__10m2003a.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iPhone SDK 3.2 Final&lt;/span&gt; with Xcode 3.2.2 for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.0)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/iphone/iphone_sdk_3.2__final/xcode_3.2.2_and_iphone_sdk_3.2_final.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.3 and iPhone SDK 4 GM seed for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.2)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/iphone/iphone_sdk_4_gm_seed/xcode_3.2.3_and_iphone_sdk_4_gm_seed.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.3 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iPhone SDK 4 Final&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.2)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/iphone/iphone_sdk_4__final/xcode_3.2.3_and_iphone_sdk_4__final.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.3 and iOS SDK 4.0.1 for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.4)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.0.1__final/xcode_3.2.3_and_ios_sdk_4.0.1.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.3 and iOS SDK 4.0.2 for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.4)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.0.2__final/xcode_3.2.3_and_ios_sdk_4.0.2.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.4 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iOS SDK 4.1&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.4)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.5 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iOS SDK 4.2 GM&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.4)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_gm_seed/xcode_3.2.5_and_ios_sdk_4.2_gm_seed.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.5 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iOS SDK 4.2&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.4)&lt;br /&gt;http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.6 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iOS SDK 4.3 GM Seed&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;http://developer.apple.com/devcenter/download.action?path=/ios/ios_sdk_4.3_gm_seed/xcode_3.2.6_and_ios_sdk_4.3_gm_seed.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.6 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iOS SDK 4.3&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;http://adcdownload.apple.com/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3__final.dmg&lt;br /&gt;&lt;br /&gt;Xcode 3.2.6 and &lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;iOS SDK 4.3.1&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;http://adcdownload.apple.com/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4 and iOS SDK 4.3&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.0.1 and iOS SDK 4.3.1&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.0.1_and_ios_sdk_4.3/xcode_4.0.1_and_ios_sdk_4.3.dmg&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.0.2 and iOS SDK 4.3.2&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.0.2_and_ios_sdk_4.3/xcode_4.0.2_and_ios_sdk_4.3.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.1&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_snow_leopard_21110/xcode_4.1_for_snow_leopard.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.1&lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Lion&lt;/span&gt; (10.7)&lt;br /&gt;https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_lion/xcode_4.1_for_lion.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.2 and iOS SDK 5.0 &lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Snow Leopard&lt;/span&gt; (10.6.6)&lt;br /&gt;https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.2_for_snow_leopard/xcode_4.2_for_snow_leopard.dmg&lt;br /&gt;&lt;br /&gt;https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.2_with_ios_5_sdk/xcode_4.2_and_ios_5_sdk_for_snow_leopard.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.2 and iOS SDK 5.0 &lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Lion&lt;/span&gt; (10.7)&lt;br /&gt;https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.2_for_lion_21179/xcode_4.2_for_lion.dmg&lt;br /&gt;&lt;br /&gt;http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.2_with_ios_5_sdk/xcode_4.2_and_ios_5_sdk_for_lion.dmg&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 255);"&gt;Xcode 4.2.1 and iOS SDK 5.0 &lt;/span&gt; for &lt;span style="font-weight:bold;"&gt;Lion&lt;/span&gt; (10.7)&lt;br /&gt;https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.2.1_for_lion/xcode_4.2.1_for_lion.dmg&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2643975082763653111?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2643975082763653111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2643975082763653111' title='52 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2643975082763653111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2643975082763653111'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2010/04/old-versions-of-iphone-sdk.html' title='Old versions of iPhone SDK'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>52</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2343804747011447463</id><published>2009-12-26T02:19:00.025+08:00</published><updated>2010-06-16T11:30:15.870+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><title type='text'>iPhone SDK 3.0 API Explorer</title><content type='html'>The previous version is for OS 2.2 and is here&lt;br /&gt;&lt;a href="http://iphonesdkdev.blogspot.com/2008/12/iphone-sdk-api-explorer.html"&gt;http://iphonesdkdev.blogspot.com/2008/12/iphone-sdk-api-explorer.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It is now updated to support OS 3.0 and with on-line reference to Erica Sadun 3.1.2 class documentation&lt;br /&gt;&lt;br /&gt;Installation Instructions: &lt;br /&gt;&lt;br /&gt;Cydia Source : http://cydia.iphone.org.hk/apt/ &lt;br /&gt;Section: Utilities &lt;br /&gt;Name: API Explorer 3.0&lt;br /&gt;&lt;br /&gt;Updated source code for version 3.0 is here&lt;br /&gt;&lt;code&gt;svn checkout http://apiexplorer.googlecode.com/svn/trunk/apiexplorer3&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;or download it (revision 25) here&lt;br /&gt;&lt;a href="http://apiexplorer.googlecode.com/files/apiexplorer3.zip"&gt;http://apiexplorer.googlecode.com/files/apiexplorer3.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The project can be built using Xcode or iphone gcc.  The Makefile has been updated, so that it can be compiled under iphone gcc for 3.0 framework.  Refer &lt;a href="http://iphonesdkdev.blogspot.com/2009/10/how-to-compile-mobilesubstrate.html"&gt;here&lt;/a&gt; for the 3.0 headers for iphone gcc.&lt;br /&gt;&lt;br /&gt;The Cydia version did not have all the frameworks (e.g. GameKit and others).  To explore more frameworks, you need to download the source code and build your own version. &lt;br /&gt;&lt;br /&gt;For Xcode, just add the required frameworks before build.  For iphone gcc, just add LDFLAGS (like the one below) in the Makefile and then &lt;i&gt;make install&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;LDFLAGS += -framework GameKit&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you want to have on-line reference to 3.0.0 framework instead of 3.1.2 from Erica's website, you should build your code.plist.  Here is the script to dump the dictionary key-string pairs for 3.0.0&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;curl -s -L  http://ericasadun.com/iPhoneDocs300/annotated.html | grep "tr..td" | sed -e "s/^.*href=\"\(.*html\)\".\(.*\)\/a.*$/\&amp;lt;key\&amp;gt;\2\/key\&amp;gt;\&amp;lt;string\&amp;gt;\1\&amp;lt;\/string\&amp;gt;/g;"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/62581-apiexplorer3.png"/&gt;&lt;br /&gt;&lt;br /&gt;This is how to dump the method name to class key-string values&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;method2class.plist  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;for page in "" _0x61 _0x62 _0x63 _0x64 _0x65 _0x66 _0x67 _0x68 _0x69 _0x6a _0x6b _0x6c _0x6d _0x6e _0x6f _0x70 _0x71 _0x72 _0x73 _0x74 _0x75 _0x76 _0x77 _0x78 _0x79 _0x7a ; do&lt;br /&gt;curl -s -L http://ericasadun.com/iPhoneDocs312/functions_func${page}.html | awk '/^.li./{s=$0;next}{print s " "$0}' | sed -e "s/^.li.\(.*\)\s[:,].*a\sclass..el..href..*html.*\"&amp;gt;\(.*\)&amp;lt;\/a&amp;gt;$/\&amp;lt;key\&amp;gt;\1\&amp;lt;\/key\&amp;gt;\&amp;lt;array\&amp;gt;\&amp;lt;string\&amp;gt;\2\&amp;lt;\/string\&amp;gt;\&amp;lt;\/array\&amp;gt;/g;" | grep "&amp;lt;key&amp;gt;"  | sed -e "s/(.*)//g" | awk -F "&amp;lt;/key&amp;gt;" '!arr[$1] {arr[$1] = $0; next} {arr[$1] = arr[$1] " " $2} END {for(i in arr) {print arr[i]}}' | sed -e "s/&amp;lt;\/array&amp;gt; &amp;lt;array&amp;gt;//g"&lt;br /&gt;done&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Latest screen dump for version 3.1 (not yet released)&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/62662-apiexplorer31.png"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2343804747011447463?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2343804747011447463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2343804747011447463' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2343804747011447463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2343804747011447463'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/12/iphone-sdk-30-api-explorer.html' title='iPhone SDK 3.0 API Explorer'/><author><name>javacom</name><uri>http://www.blogger.com/profile/10745838995139328314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2848659148188852825</id><published>2009-12-09T22:34:00.021+08:00</published><updated>2009-12-11T07:53:45.822+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SmartScreen Widget'/><category scheme='http://www.blogger.com/atom/ns#' term='Makefile'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone GCC'/><title type='text'>[How-to] compile SmartScreen widget in iphone gcc</title><content type='html'>Here is a sample clock widget source from SmartScreen sdk http://media-phone.ch/en/software/smartscreen/sdk/ ,  I added a Makefile so that it can be compiled under iphone gcc&lt;br /&gt;&lt;br /&gt;&lt;a href="http://apiexplorer.googlecode.com/files/ClockWidget.zip"&gt;http://apiexplorer.googlecode.com/files/ClockWidget.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Make sure you have installed iphone gcc and 3.0 headers (refer &lt;a href="http://iphonesdkdev.blogspot.com/2009/10/how-to-compile-mobilesubstrate.html"&gt;here&lt;/a&gt; for the 3.0 headers) and also SmartScreen (Lite or full version) before your testing.&lt;br /&gt;&lt;br /&gt;If you have installed toolchain and 3.0 headers under cygwin or linux, just modify the sdk location in the Makefile and it should compile as well.&lt;br /&gt;&lt;br /&gt;SmartScreen widget will be installed under the folder /var/mobile/Library/SmartScreen &lt;br /&gt;&lt;br /&gt;To compile and install this sample clock widget under iphone gcc&lt;br /&gt;&lt;code&gt;&lt;br /&gt;make &lt;br /&gt;make install&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To uninstall the clock widget&lt;br /&gt;&lt;code&gt;&lt;br /&gt;make uninstall&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This is the updated Makefile for SmartScreen ClockWidget&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;# Makefile for gcc compiler for iPhone (SmartScreen Widget)&lt;br /&gt;&lt;br /&gt;PROJECTNAME:=Clock&lt;br /&gt;PRINCIPALCLASS:=$(PROJECTNAME)Widget&lt;br /&gt;WIDGETFOLDER:=$(PROJECTNAME).wdgt&lt;br /&gt;INSTALLFOLDER:=/var/mobile/Library/SmartScreen&lt;br /&gt;MINIMUMVERSION:=3.0&lt;br /&gt;&lt;br /&gt;CC:=arm-apple-darwin9-gcc&lt;br /&gt;CPP:=arm-apple-darwin9-g++&lt;br /&gt;LD:=$(CC)&lt;br /&gt;SDK:=/var/toolchain/sys30&lt;br /&gt;&lt;br /&gt;LDFLAGS = -arch arm -lobjc &lt;br /&gt;LDFLAGS += -framework CoreFoundation &lt;br /&gt;LDFLAGS += -framework Foundation &lt;br /&gt;LDFLAGS += -framework UIKit &lt;br /&gt;LDFLAGS += -framework CoreGraphics&lt;br /&gt;//LDFLAGS += -framework AddressBook&lt;br /&gt;//LDFLAGS += -framework AddressBookUI&lt;br /&gt;//LDFLAGS += -framework AudioToolbox&lt;br /&gt;//LDFLAGS += -framework AudioUnit&lt;br /&gt;//LDFLAGS += -framework AVFoundation&lt;br /&gt;//LDFLAGS += -framework CoreSurface&lt;br /&gt;//LDFLAGS += -framework CoreAudio&lt;br /&gt;//LDFLAGS += -framework CoreData&lt;br /&gt;//LDFLAGS += -framework CFNetwork&lt;br /&gt;//LDFLAGS += -framework GraphicsServices&lt;br /&gt;//LDFLAGS += -framework OpenAL&lt;br /&gt;//LDFLAGS += -framework OpenGLES&lt;br /&gt;//LDFLAGS += -framework MediaPlayer&lt;br /&gt;//LDFLAGS += -framework QuartzCore&lt;br /&gt;//LDFLAGS += -framework Security&lt;br /&gt;//LDFLAGS += -framework SystemConfiguration&lt;br /&gt;//LDFLAGS += -framework WebCore&lt;br /&gt;//LDFLAGS += -framework WebKit&lt;br /&gt;//LDFLAGS += -framework SpringBoardUI&lt;br /&gt;//LDFLAGS += -framework TelephonyUI&lt;br /&gt;//LDFLAGS += -framework JavaScriptCore&lt;br /&gt;//LDFLAGS += -framework PhotoLibrary&lt;br /&gt;LDFLAGS += -L"$(SDK)/usr/lib"&lt;br /&gt;LDFLAGS += -F"$(SDK)/System/Library/Frameworks"&lt;br /&gt;LDFLAGS += -F"$(SDK)/System/Library/PrivateFrameworks"&lt;br /&gt;LDFLAGS += -bind_at_load&lt;br /&gt;LDFLAGS += -multiply_defined suppress&lt;br /&gt;LDFLAGS += -march=armv6&lt;br /&gt;LDFLAGS += -mcpu=arm1176jzf-s &lt;br /&gt;LDFLAGS += -mmacosx-version-min=10.5&lt;br /&gt;LDFLAGS += -dynamiclib&lt;br /&gt;&lt;br /&gt;CFLAGS += -I"$(SDK)/usr/include" &lt;br /&gt;CFLAGS += -DDEBUG -std=gnu99 -O0&lt;br /&gt;CFLAGS += -Diphoneos_version_min=$(MINIMUMVERSION)&lt;br /&gt;CFLAGS += -Wno-attributes -Wno-trigraphs -Wreturn-type -Wunused-variable&lt;br /&gt;&lt;br /&gt;BUILDDIR=./build/$(MINIMUMVERSION)&lt;br /&gt;SRCDIR=./&lt;br /&gt;RESDIR=./Resources&lt;br /&gt;OBJS+=$(patsubst %.m,%.o,$(wildcard $(SRCDIR)/*.m))&lt;br /&gt;OBJS+=$(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))&lt;br /&gt;OBJS+=$(patsubst %.mm,%.o,$(wildcard $(SRCDIR)/*.mm))&lt;br /&gt;OBJS+=$(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/*.cpp))&lt;br /&gt;OBJS+=$(patsubst %.m,%.o,$(wildcard ./*.m))&lt;br /&gt;PCH=$(wildcard *.pch)&lt;br /&gt;RESOURCES=$(wildcard $(RESDIR)/*)&lt;br /&gt;&lt;br /&gt;CFLAGS += $(addprefix -I,$(SRCDIR))&lt;br /&gt;&lt;br /&gt;CPPFLAGS=$CFLAGS&lt;br /&gt;&lt;br /&gt;all: $(PROJECTNAME)&lt;br /&gt;&lt;br /&gt;$(PROJECTNAME): $(OBJS) Makefile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(LD) $(LDFLAGS) $(filter %.o,$^) -o $@&lt;br /&gt;&lt;br /&gt;%.o: %.m %.h $(PCH) $(filter-out $(patsubst %.o,%.h,$(OBJS)), $(wildcard $(SRCDIR)/*.h))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(CC) --include $(PCH) -c $(CFLAGS) $&lt; -o $@&lt;br /&gt;&lt;br /&gt;%.o: %.c %.h $(PCH)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(CC) --include $(PCH) -c $(CFLAGS) $&lt; -o $@&lt;br /&gt;&lt;br /&gt;%.o: %.mm %.h $(PCH) $(filter-out $(patsubst %.o,%.h,$(OBJS)), $(wildcard $(SRCDIR)/*.h))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(CPP) --include $(PCH) -c $(CPPFLAGS) $&lt; -o $@&lt;br /&gt;&lt;br /&gt;%.o: %.cpp %.h $(PCH)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(CPP) --include $(PCH) -c $(CPPFLAGS) $&lt; -o $@&lt;br /&gt;&lt;br /&gt;dist: $(PROJECTNAME) Info.plist Makefile $(RESOURCES)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -rf $(BUILDDIR)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@mkdir -p $(BUILDDIR)/$(WIDGETFOLDER)&lt;br /&gt;ifneq ($(RESOURCES),)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@-cp -r $(RESOURCES) $(BUILDDIR)/$(WIDGETFOLDER)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@-$(foreach DIR, .svn .DS_Store .git* , find $(BUILDDIR)/$(APPFOLDER) -name '$(DIR)' -prune -exec rm -rfv {} \;;)&lt;br /&gt;endif&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@cp Info.plist $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@./plutil -key CFBundleExecutable -value $(PROJECTNAME) $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@./plutil -key CFBundleName -value $(PROJECTNAME) $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@./plutil -key NSPrincipalClass -value $(PRINCIPALCLASS) $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ldid -S $(PROJECTNAME)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@mv $(PROJECTNAME) $(BUILDDIR)/$(WIDGETFOLDER)&lt;br /&gt;&lt;br /&gt;install: dist&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -fr $(INSTALLFOLDER)/$(WIDGETFOLDER)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp -r $(BUILDDIR)/$(WIDGETFOLDER) $(INSTALLFOLDER)/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@chown -R mobile:mobile $(INSTALLFOLDER)/$(WIDGETFOLDER)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@echo "Widget $(WIDGETFOLDER) installed, please respring device"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@./respring&lt;br /&gt;&lt;br /&gt;uninstall:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -fr $(INSTALLFOLDER)/$(WIDGETFOLDER)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@./respring&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@echo "Widget $(WIDGETFOLDER) uninstalled, please respring device"&lt;br /&gt;&lt;br /&gt;install_respring:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cp ./respring /usr/bin/respring&lt;br /&gt;&lt;br /&gt;distclean:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -rf $(BUILDDIR)&lt;br /&gt;&lt;br /&gt;clean:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -f $(OBJS)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -rf $(BUILDDIR)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@rm -f $(PROJECTNAME)&lt;br /&gt;&lt;br /&gt;.PHONY: all dist install uninstall install_respring distclean clean&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2848659148188852825?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2848659148188852825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2848659148188852825' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2848659148188852825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2848659148188852825'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/12/how-to-compile-smartscreen-widget-in.html' title='[How-to] compile SmartScreen widget in iphone gcc'/><author><name>javacom</name><uri>http://www.blogger.com/profile/10745838995139328314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-5895055687947744406</id><published>2009-11-25T22:05:00.005+08:00</published><updated>2009-11-26T07:30:46.416+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Wave'/><category scheme='http://www.blogger.com/atom/ns#' term='Drag and Drop'/><title type='text'>Google Wave, Drag and Drop ?</title><content type='html'>Want to enable drag and drop in google wave for your browser ?&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sw27Y5_0JQI/AAAAAAAAAxg/zFwMXSUFcBM/s1600/gearinstalled.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 373px; height: 262px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sw27Y5_0JQI/AAAAAAAAAxg/zFwMXSUFcBM/s400/gearinstalled.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5408184764101567746" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Install google gears here&lt;br /&gt;&lt;br /&gt;&lt;a href="http://gears.google.com"&gt;http://gears.google.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/61731-googlegear-embed.png"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sw2-DX2HtFI/AAAAAAAAAxo/S40fzSkwHdc/s1600/javacomhk.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 226px; height: 20px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sw2-DX2HtFI/AAAAAAAAAxo/S40fzSkwHdc/s400/javacomhk.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5408187692691731538" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-5895055687947744406?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/5895055687947744406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=5895055687947744406' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5895055687947744406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5895055687947744406'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/11/google-wave-drag-and-drop.html' title='Google Wave, Drag and Drop ?'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/Sw27Y5_0JQI/AAAAAAAAAxg/zFwMXSUFcBM/s72-c/gearinstalled.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3426476039305449594</id><published>2009-11-23T23:28:00.004+08:00</published><updated>2009-12-11T00:59:46.773+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Cycript'/><title type='text'>Where is Cycript ?</title><content type='html'>Cycrypt is a new project that blends Objective-C and JavaScript to make it easier to implement aspects of both together.&lt;br /&gt;and here it is&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cycript.org/"&gt;http://www.cycript.org/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Examples are here&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cycript.org/examples/"&gt;http://www.cycript.org/examples/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Dial with Cycript: [SBTTYPromptAlert dialNumberPromptingIfNecessary:"+18885551234" addressBookUID:-1 urlAddition:"wasLockAlert=1"];&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3426476039305449594?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3426476039305449594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3426476039305449594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3426476039305449594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3426476039305449594'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/11/where-is-cycript.html' title='Where is Cycript ?'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2086182564591447535</id><published>2009-11-22T14:34:00.019+08:00</published><updated>2011-11-27T11:46:54.569+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='git'/><title type='text'>How to create local and remote ssh git repo in Mac OS X</title><content type='html'>(1) Install git for Mac OS X&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mkdir ~/src&lt;br /&gt;cd ~/src/&lt;br /&gt;curl -O http://kernel.org/pub/software/scm/git/git-1.6.5.3.tar.bz2&lt;br /&gt;tar -xjvf git-1.6.5.3.tar.bz2&lt;br /&gt;cd git-1.6.5.3&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;git --version&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(2) Suppose you have a project in ~/myproject&lt;br /&gt;and the remote ssh server login is user@xxx.xxx.xxx.xxx&lt;br /&gt;both client and server have git installed&lt;br /&gt;&lt;br /&gt;(3) Create localrepo in local harddisk&lt;br /&gt;&lt;code&gt;&lt;br /&gt;git mkdir -p ~/git&lt;br /&gt;git clone --bare ~/myproject ~/git/myproject.git&lt;br /&gt;touch ~/git/myproject.git/git-daemon-export-ok&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;push to localrepo&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd ~/myproject&lt;br /&gt;git init&lt;br /&gt;git add .&lt;br /&gt;git rm -r --cache build &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# ignore the build directory for iPhone project&lt;br /&gt;git commit -m 'Initial commit'&lt;br /&gt;git remote add localrepo ~/git/myproject.git&lt;br /&gt;git push localrepo master&lt;br /&gt;git log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) Create sshrepo in remote server over ssh&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ssh user@xxx.xxx.xxx.xxx "mkdir -p /Volumes/HD/git/myproject.git; cd /Volumes/HD/git/myproject.git; git --bare init; touch git-daemon-export-ok"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;check the location of remote git binary and the remote ssh login shell&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ssh user@xxx.xxx.xxx.xxx "which git-upload-pack"&lt;br /&gt;ssh user@xxx.xxx.xxx.xxx "echo \$PATH"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;mine is /usr/local/bin/git-upload-pack&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if the remote login shell does not include path of git, create ~/.bashrc in your remote ssh login shell&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ssh user@xxx.xxx.xxx.xxx "echo 'export PATH=\${PATH}:/usr/local/bin' &gt; ~/.bashrc"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;push to sshrepo&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd ~/myproject&lt;br /&gt;git remote add sshrepo ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/myproject.git&lt;br /&gt;git push sshrepo master&lt;br /&gt;git log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#660000;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Test git clone&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd ~&lt;br /&gt;git clone ~/git/myproject.git workinglocal&lt;br /&gt;cd workinglocal&lt;br /&gt;git log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd ~&lt;br /&gt;git clone ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/myproject.git workingremote&lt;br /&gt;cd workingremote&lt;br /&gt;git log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#660000;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;How to Branch&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;git branch -r &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# show branch in repo&lt;br /&gt;git checkout -b todo origin/to-do-branch  # checkout a new branch&lt;br /&gt;git checkout master &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# checkout the master branch&lt;br /&gt;&lt;br /&gt;git checkout localrepo/master # checkout the master branch in localrepo&lt;br /&gt;git checkout sshrepo/master &amp;nbsp;&amp;nbsp;# checkout the master branch in sshrepo&lt;br /&gt;&lt;br /&gt;git branch next  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# create new branch&lt;br /&gt;git add .&lt;br /&gt;git commit -m 'commit nextbranch'&lt;br /&gt;git push localrepo next&lt;br /&gt;&lt;br /&gt;git branch -b cygwin&lt;br /&gt;git branch -r&lt;br /&gt;git add *&lt;br /&gt;git commit -m 'commit cygwin branch'&lt;br /&gt;git push origin cygwin&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#660000;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;How to checkout a previous commit&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;git log         # show log of previous commit&lt;br /&gt;git log --format=oneline   # show log of previous commit log hex digit&lt;br /&gt;git checkout 838fbf2e9b050d2350694235bbf5e9a11fa7acea  # commit log hexdigit&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#660000;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;How to push to github&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;git config --global user.name "javacom"&lt;br /&gt;git config --global user.email "javacomhk@yahoo.com"&lt;br /&gt;git remote rm origin&lt;br /&gt;git remote add origin git@github.com:javacom/toolchain4.git&lt;br /&gt;git push origin master&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2086182564591447535?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2086182564591447535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2086182564591447535' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2086182564591447535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2086182564591447535'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/11/how-to-create-local-and-remote-ssh-git.html' title='How to create local and remote ssh git repo in Mac OS X'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-6784227176450140834</id><published>2009-10-04T15:08:00.029+08:00</published><updated>2010-09-22T15:04:37.871+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobilesubstrate'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone GCC'/><title type='text'>How to compile mobilesubstrate extension in iPhone gcc for OS 3.0</title><content type='html'>(1) You need iphone gcc installed in your jailbroken iPhone / iPod Touch with firmware 3.0 or above&lt;br /&gt;&lt;br /&gt;iPhone gcc is available in Cydia.  To install it in you need to do these&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# assume you have installed &lt;span style="font-style:italic;"&gt;APT 0.6 Transitional&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;Aptitude&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;wget&lt;/span&gt; in Cydia, so that you can use the command apt-get&lt;br /&gt;# if libgcc is broken in Cydia, you have to install it manually before iphone-gcc&lt;br /&gt;wget http://apt.saurik.com/debs/libgcc_4.2-20080410-1-6_iphoneos-arm.deb &lt;br /&gt;dpkg -i libgcc_4.2-20080410-1-6_iphoneos-arm.deb &lt;br /&gt;# install iphone-gcc&lt;br /&gt;apt-get install iphone-gcc &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Moreover, you need these utilities as well&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;apt-get install make ldid zip unzip wget&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;for editor in iPhone you can use &lt;span style="font-style:italic;"&gt;vim&lt;/span&gt; or &lt;span style="font-style:italic;"&gt;nano&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(2) You need the header files of toolchain and SDK 3.0, libsubstrate and classdump the SpringBoard and UIKit headers&lt;br /&gt;&lt;br /&gt;The building of iPhone gcc in Linux and header files (updated for OS 3.0) is here in&lt;br /&gt;&lt;a href="http://www.saurik.com/id/4"&gt;http://www.saurik.com/id/4&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The updated mobilesubtrate header files are &lt;a href="http://svn.saurik.com/repos/menes/trunk/mobilesubstrate/"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The classdump procedure is &lt;a href="http://iphonesdkdev.blogspot.com/2009/05/how-to-classdump-springboard-header.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;But all these involved a lot of downloading and patching, so I put all the downloading/classdump/patching in one zipped tar file (sys30.tgz).  You can download it (about 96M) &lt;a href="http://www.2shared.com/file/8211431/8b305517/sys30.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(3) copy and untar the required headers and libraries (say copy to /var/mobile/sys30.tgz) and install it in iPhone / iPod Touch say&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mkdir /var/toolchain/&lt;br /&gt;cd /var/toolchain/&lt;br /&gt;tar -xzvf /var/mobile/sys30.tgz&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) Use this sample mobilesubstrate extension (ExampleHook.zip) and unzip it to test.  You need to apt-get install mobilesubstrate in iPhone / iPod Touch first&lt;br /&gt;&lt;br /&gt;&lt;a href="http://apiexplorer.googlecode.com/files/ExampleHook.zip"&gt;http://apiexplorer.googlecode.com/files/ExampleHook.zip&lt;/a&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;apt-get install mobilesubstrate&lt;br /&gt;wget http://apiexplorer.googlecode.com/files/ExampleHook.zip&lt;br /&gt;unzip ExampleHook.zip&lt;br /&gt;cd ExampleHook&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;make (to compile and codesign)&lt;br /&gt;make install (to install), after install you need respring the device to test&lt;br /&gt;make uninstall (to uninstall), after uninstall you need respring as well&lt;br /&gt;&lt;br /&gt;respring utility is available from my cydia source &lt;span style="font-style:italic;"&gt;http://cydia.iphone.org.hk/apt/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(5) You can also checkout a copy of the iphone backgrounder to test your iphone gcc and mobilesubstrate development environment&lt;br /&gt;&lt;a href="http://code.google.com/p/iphone-backgrounder/source/checkout"&gt;http://code.google.com/p/iphone-backgrounder/source/checkout&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Install subversion before using svn in iPhone / iPod Touch&lt;br /&gt;&lt;code&gt;&lt;br /&gt;apt-get install subversion&lt;br /&gt;svn checkout http://iphone-backgrounder.googlecode.com/svn/trunk/ iphone-backgrounder&lt;br /&gt;cd iphone-backgrounder&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I use this modified Makefile to compile iphone-backgrounder&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile&lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;NAME = Backgrounder&lt;br /&gt;APP_ID = jp.ashikase.backgrounder&lt;br /&gt;&lt;br /&gt;# These paths must be changed to match the compilation environment&lt;br /&gt;TOOLCHAIN = /var/toolchain/sys30/dump&lt;br /&gt;SYS_PATH = /var/toolchain/sys30&lt;br /&gt;MS_PATH = /var/toolchain/sys30/mobilesubstrate&lt;br /&gt;INC_PATH = /var/toolchain/sys30/usr/include&lt;br /&gt;LDID = /usr/bin/ldid&lt;br /&gt;&lt;br /&gt;CXX = arm-apple-darwin9-g++&lt;br /&gt;CXXFLAGS = -g0 -O2 -Wall -Werror -Wno-write-strings -include common.h -DAPP_ID=\"$(APP_ID)\"&lt;br /&gt;LD = $(CXX)&lt;br /&gt;LDFLAGS = -march=armv6 \&lt;br /&gt;   -mcpu=arm1176jzf-s \&lt;br /&gt;   -bind_at_load \&lt;br /&gt;   -multiply_defined suppress \&lt;br /&gt;   -framework CoreFoundation \&lt;br /&gt;   -framework Foundation \&lt;br /&gt;   -framework UIKit \&lt;br /&gt;   -framework GraphicsServices \&lt;br /&gt;   -framework CoreGraphics \&lt;br /&gt;   -F$(SYS_PATH)/System/Library/Frameworks \&lt;br /&gt;   -F$(SYS_PATH)/System/Library/PrivateFrameworks \&lt;br /&gt;   -L$(SYS_PATH)/usr/lib -lsubstrate \&lt;br /&gt;   -lobjc&lt;br /&gt;&lt;br /&gt;INCLUDES =  -I$(INC_PATH) -I$(MS_PATH) -I$(TOOLCHAIN) \&lt;br /&gt;   -I./Classes&lt;br /&gt;&lt;br /&gt;SUBDIRS    = . Classes&lt;br /&gt;&lt;br /&gt;DIRLIST    := $(SUBDIRS:%=%)&lt;br /&gt;SRCS       := $(foreach dir,$(DIRLIST), $(wildcard $(dir)/*.mm))&lt;br /&gt;HDRS       := $(foreach dir,$(DIRLIST), $(wildcard $(dir)/*.h))&lt;br /&gt;OBJS       := $(SRCS:.mm=.o)&lt;br /&gt;&lt;br /&gt;all: $(NAME).dylib&lt;br /&gt;&lt;br /&gt;config:&lt;br /&gt; ln -snf $(TOOLCHAIN) $(SYS_PATH)&lt;br /&gt;&lt;br /&gt;# Replace 'iphone' with the IP or hostname of your device&lt;br /&gt;install: config $(NAME).dylib&lt;br /&gt; ssh root@iphone rm -f /Library/MobileSubstrate/DynamicLibraries/$(NAME).dylib&lt;br /&gt; scp $(NAME).dylib root@iphone:/Library/MobileSubstrate/DynamicLibraries/&lt;br /&gt; ssh root@iphone restart&lt;br /&gt;&lt;br /&gt;$(NAME).dylib: $(OBJS) $(HDRS)&lt;br /&gt; $(LD) -dynamiclib $(LDFLAGS) $(OBJS) -init _$(NAME)Initialize -o $@&lt;br /&gt; $(LDID) -S $@&lt;br /&gt;&lt;br /&gt;%.o: %.mm&lt;br /&gt; $(CXX) $(CXXFLAGS) $(INCLUDES) -c $&amp;lt; -o $@&lt;br /&gt;    &lt;br /&gt;clean:&lt;br /&gt; rm -f $(OBJS) $(NAME).dylib&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;P.S.  This is how to compile a standard c++ program in iPhone gcc&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;test.cpp&lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;arm-apple-darwin9-g++ -I"/var/toolchain/sys30/usr/include" -I"/var/toolchain/sys30/usr/include/c++/4.2.1" -I"/var/toolchain/sys30/usr/include/c++/4.2.1/armv6-apple-darwin9" -g0 -O2 -Wall  -L"/var/toolchain/sys30/usr/lib" -march=armv6 -mcpu=arm1176jzf-s test.cpp -o test&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-6784227176450140834?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/6784227176450140834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=6784227176450140834' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6784227176450140834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6784227176450140834'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/10/how-to-compile-mobilesubstrate.html' title='How to compile mobilesubstrate extension in iPhone gcc for OS 3.0'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2689797939627052368</id><published>2009-08-02T09:57:00.025+08:00</published><updated>2009-11-21T17:22:59.119+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='subversion'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 2.2.1 and 3.0 compatible'/><title type='text'>Compatible code for OS 2.2.1 and 3.0</title><content type='html'>Recently, the itts apple server has a number of changes and one of my favourite opensource app AppSales Mobile failed to get the sales data.  It is now updated and thanks to the developer for the updating&lt;br /&gt;&lt;br /&gt;&lt;a href="http://github.com/omz/AppSales-Mobile/"&gt;http://github.com/omz/AppSales-Mobile/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, the project was set to compile for SDK3.0,  there are only a few changes that need to bring this app to be compatible to OS 2.2.1 and 3.0 at the same time.&lt;br /&gt;&lt;br /&gt;Here are the steps involved&lt;br /&gt;&lt;br /&gt;(1) Base SDK set to iPhone Device 3.0&lt;br /&gt;(2) In Project Settings, iPhone OS Deployment Target set to iPhone OS 2.2.1&lt;br /&gt;(3) Change the source code in RootViewController.m that have &lt;span style="font-weight:bold;"&gt;setFont&lt;/span&gt; or &lt;span style="font-weight:bold;"&gt;setImage&lt;/span&gt; methods, there are about 18 such changes to be done.&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;This is how to change the source code by adding respondsToSelector: test before using the deprecated method&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br/&gt;change from&lt;br/&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;[footer.titleLabel setFont:[UIFont systemFontOfSize:14.0]];&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br/&gt;to&lt;br/&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if ( [footer respondsToSelector:@selector(setFont:)] ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[footer setFont:[UIFont systemFontOfSize:14.0]];&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[footer.titleLabel setFont:[UIFont systemFontOfSize:14.0]];&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br/&gt;change from&lt;br/&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;cell.imageView.image = [UIImage imageNamed:@"Daily.png"];&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br/&gt;to&lt;br/&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if ( [cell respondsToSelector:@selector(setImage:)] ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cell.image = [UIImage imageNamed:@"Daily.png"];&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cell.imageView.image = [UIImage imageNamed:@"Daily.png"];&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You may get warnings when build to actual 2.2.1 OS device, but this is normal.  However, you cannot build to 2.2.1 Simulator.&lt;br /&gt;&lt;br /&gt;The modified source is available here&lt;br /&gt;&lt;a href="http://code.google.com/p/apiexplorer/source/detail?r=20"&gt;http://code.google.com/p/apiexplorer/source/detail?r=20&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Revision 20 is a modified source (as above) for version 2009/7&lt;br /&gt;&lt;br /&gt;Revision 23 is the updated modification for version 2009/11/19&lt;br /&gt;&lt;br /&gt;to checkout a revision&lt;br /&gt;&lt;code&gt;&lt;br /&gt;svn checkout -r 20 http://apiexplorer.googlecode.com/svn/branches/AppSalesMobile221 AppSalesMobile221r20&lt;br /&gt;svn checkout -r 23 http://apiexplorer.googlecode.com/svn/branches/AppSalesMobile221 AppSalesMobile221r23&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want to check out a previous version based on the commit hexdigit from the github repo, do this&lt;br /&gt;&lt;code&gt;&lt;br /&gt;git clone git://github.com/omz/AppSales-Mobile.git AppSales0731&lt;br /&gt;cd AppSales0731&lt;br /&gt;git checkout -b b0731 ff248e8e6c23386f867514c1c331a469b7d4cf45&lt;br /&gt;git log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2689797939627052368?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2689797939627052368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2689797939627052368' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2689797939627052368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2689797939627052368'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/08/compatible-code-for-os-221-and-30.html' title='Compatible code for OS 2.2.1 and 3.0'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-6797959616839791187</id><published>2009-08-01T22:54:00.005+08:00</published><updated>2009-08-01T23:12:04.024+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javacom'/><title type='text'>javacom change name</title><content type='html'>I have been asked by Sun Microsystems to change my App Store name to others stating that &lt;span style="font-weight:bold;"&gt;Javacom is an Unauthorized use of Java Trademark&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/SnRZ4cWPrmI/AAAAAAAAAxI/SFyog0i_WQM/s1600-h/javacom.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 222px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/SnRZ4cWPrmI/AAAAAAAAAxI/SFyog0i_WQM/s400/javacom.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5365011882322144866" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Obviously, I don't have the ability to counter with their request.  But I have a few words to say&lt;br /&gt;&lt;br /&gt;First of all,  my name in App Store is javacom not Javacom&lt;br /&gt;Second, Java and Java applet are not supported by official iPhone App Store app or web app.&lt;br /&gt;Third, I did not program in Java, I only drink a cup of java when I do programming.&lt;br /&gt;&lt;br /&gt;May be I have to drink milk instead.... Coffee may not be good for me&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-6797959616839791187?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/6797959616839791187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=6797959616839791187' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6797959616839791187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6797959616839791187'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/08/javacom-change-name.html' title='javacom change name'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/SnRZ4cWPrmI/AAAAAAAAAxI/SFyog0i_WQM/s72-c/javacom.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2676337036730921918</id><published>2009-07-27T07:00:00.006+08:00</published><updated>2009-07-28T07:32:21.551+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Email Signature'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>Picture Icon in email signature for iPhone</title><content type='html'>How to add CSS signature to your iPhone ?&lt;br /&gt;&lt;br /&gt;The previous hack was to change the Preferences Settings for jailbreaked iPhone.  But I have a better approach for non-jailbreaked iPhone, and with custom picture email signature as well. It works for 2.x firmware.&lt;br /&gt;&lt;br /&gt;This will be a new functionality for my app &lt;a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=286534260&amp;mt=8"&gt;Touch Dial Emoji&lt;/a&gt; (version 2.0) in App Store.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;See screenshots here&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/57231-touchdialemojiv2-embed.jpg"/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2676337036730921918?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2676337036730921918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2676337036730921918' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2676337036730921918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2676337036730921918'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/07/picture-icon-in-email-signature-for.html' title='Picture Icon in email signature for iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-5396109218959699257</id><published>2009-07-12T08:01:00.029+08:00</published><updated>2009-08-22T19:58:18.745+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 2.2.1 and 3.0 compatible'/><category scheme='http://www.blogger.com/atom/ns#' term='weak linking'/><title type='text'>How to build a single iPhone application support both 2.x and 3.0 at the same time</title><content type='html'>I asked Apple Technical Support on how to build an iPhone application that runs on iPhone OS 2.x and yet uses iPhone OS 3.0 features if they are available.&lt;br /&gt;&lt;br /&gt;They replied with a solution called weak linking&lt;br /&gt;&lt;br /&gt;What is weak linking as quoted from &lt;a href="http://devworld.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html"&gt;http://devworld.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;When a symbol in a framework is defined as weakly linked, the symbol does not have to be present at runtime for a process to continue running. The static linker identifies a weakly linked symbol as such in any code module that references the symbol. The dynamic linker uses this same information at runtime to determine whether a process can continue running. If a weakly linked symbol is not present in the framework, the code module can continue to run as long as it does not reference the symbol. However, if the symbol is present, the code can use it normally.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here's the basic steps:&lt;br /&gt;&lt;br /&gt;1. Use the latest tools with the latest SDK.&lt;br /&gt;&lt;br /&gt;2. In your project, set the IPHONEOS_DEPLOYMENT_TARGET build setting to the oldest OS you want to support (say iPhone OS 2.0). And use &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;GCC 4.2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3LRNVfBfliQ/Slkr9lvXRtI/AAAAAAAAAwQ/HpbxFI4qmW0/s1600-h/deploytarget.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 216px;" src="http://1.bp.blogspot.com/_3LRNVfBfliQ/Slkr9lvXRtI/AAAAAAAAAwQ/HpbxFI4qmW0/s400/deploytarget.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5357361568836699858" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. If you use frameworks that are not present on that older OS, set the frameworks to be weak imported.  Do this using the Linked Libraries list in the General tab of the target info window.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SlksKnzwWtI/AAAAAAAAAwY/NVF_lJDjJp8/s1600-h/weaklink.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 376px; height: 166px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SlksKnzwWtI/AAAAAAAAAwY/NVF_lJDjJp8/s400/weaklink.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5357361792730290898" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if you use Makefile to build the app add this in linker flag&lt;br /&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;LDFLAGS += -weak_framework MessageUI&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and add this key in Info.plist&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;key&amp;gt;MinimumOSVersion&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;string&amp;gt;2.0&amp;lt;/string&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is how to test whether framework is available or not&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#import &amp;lt;MessageUI/MessageUI.h&amp;gt;&lt;br /&gt;#include &amp;lt;dlfcn.h&amp;gt;&lt;br /&gt;&lt;br /&gt;    if ( dlsym(RTLD_DEFAULT, "MFMailComposeErrorDomain") != NULL ) {&lt;br /&gt;        NSLog(@"%@", @"MessageUI framework is available");&lt;br /&gt;        NSLog(@"MFMailComposeErrorDomain = %@", MFMailComposeErrorDomain);&lt;br /&gt;    } else {&lt;br /&gt;        NSLog(@"%@", @"MessageUI framework is not available");&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. For places where you use C-style imports that aren't present on older systems, check whether the import is present before using it.&lt;br /&gt;&lt;br /&gt;5. If you use Objective-C methods that aren't present on older systems, use -respondsToSelector: to verify that the methods are present before calling them.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;if ( [[UIApplication sharedApplication] respondsToSelector:@selector(canOpenURL:)] ) {&lt;br /&gt;  if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:996-1010"]] ) {&lt;br /&gt;    NSLog(@"%@", @"tel URL is supported");&lt;br /&gt;  } else {&lt;br /&gt;    NSLog(@"%@", @"tel URL is not supported");&lt;br /&gt;  }&lt;br /&gt;} else {&lt;br /&gt;  NSLog(@"%@",  @"-canOpenURL: not available");&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;6. If you use Objective-C classes that aren't present on older systems, you can't just use the class directly.  For example:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;obj = [[NSUndoManager alloc] init];&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;will cause your application to fail to launch on iPhone OS 2.x, even if you weak link to the framework.  Rather, you have to do the following:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;NSUndoManager undoManager;&lt;br /&gt;Class cls;&lt;br /&gt;cls = NSClassFromString(@"NSUndoManager");&lt;br /&gt;  if (cls != nil) {&lt;br /&gt;    undoManager = [[[cls alloc] init] autorelease];&lt;br /&gt;    NSLog(@"%@", @"NSUndoManager is available");&lt;br /&gt;&lt;br /&gt;    // This tests whether we have access to NSUndoManager's selectors.&lt;br /&gt;&lt;br /&gt;    [undoManager beginUndoGrouping];&lt;br /&gt;    [undoManager endUndoGrouping];&lt;br /&gt;  } else {&lt;br /&gt;    NSLog(@"%@", @"NSUndoManager not available");&lt;br /&gt;  }&lt;br /&gt;  undoManager = nil;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;7. &lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;Test, test, test!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Updated:&lt;br /&gt;There is sample source code for the Mail Composer in Developer site&lt;br /&gt;&lt;a href="http://developer.apple.com/iphone/library/samplecode/MailComposer/index.html"&gt;http://developer.apple.com/iphone/library/samplecode/MailComposer/index.html&lt;/a&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-5396109218959699257?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/5396109218959699257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=5396109218959699257' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5396109218959699257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/5396109218959699257'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/07/how-to-build-single-iphone-application.html' title='How to build a single iPhone application support both 2.x and 3.0 at the same time'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_3LRNVfBfliQ/Slkr9lvXRtI/AAAAAAAAAwQ/HpbxFI4qmW0/s72-c/deploytarget.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-472566157554628632</id><published>2009-07-05T19:35:00.018+08:00</published><updated>2009-07-13T02:58:30.440+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone GCC'/><title type='text'>How to compile command line utility for iPhone using XCode gcc</title><content type='html'>hello.c&lt;br /&gt;&lt;code&gt;&lt;br /&gt;echo 'main() { printf("Hello, world!\n"); }' &amp;gt; hello.c&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;compile hello.c&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -arch armv6 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk -o hello hello.c&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;compile with framework&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -arch armv6 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk -framework Foundation -framework CoreFoundation -lobjc -std=c99 main.m -o main&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;codesign in Mac, if you have developer or self-signed certificate (can't codesign it when in ssh session)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate; codesign -f -s "iPhone Developer" hello&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;or you can codesign in iPhone, that is, send the binary to iPhone and then fake codesign it&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ldid -S hello&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is how to use as (assembler) to compile hello.s to ARM thumb binary&lt;br /&gt;&lt;code&gt;/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as -arch armv6 hello.s -o hello&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# GAS filename : hello.s&lt;br /&gt;# use as to compile&lt;br /&gt;# /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as -arch armv6 hello.s -o hello&lt;br /&gt;# use otool to disassemble&lt;br /&gt;# otool -tv hello&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;.globl _main&lt;br /&gt;&amp;nbsp;&amp;nbsp;.code 16&lt;br /&gt;&amp;nbsp;&amp;nbsp;.thumb_func _main&lt;br /&gt;_main:&lt;br /&gt;&amp;nbsp;&amp;nbsp;push {r7, lr}&lt;br /&gt;&amp;nbsp;&amp;nbsp;add r7, sp, #0&lt;br /&gt;&amp;nbsp;&amp;nbsp;add r3, pc&lt;br /&gt;&amp;nbsp;&amp;nbsp;mov ip, r3&lt;br /&gt;&amp;nbsp;&amp;nbsp;mov r3, ip&lt;br /&gt;&amp;nbsp;&amp;nbsp;mov r0, r3&lt;br /&gt;&amp;nbsp;&amp;nbsp;pop {r7, pc}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-472566157554628632?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/472566157554628632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=472566157554628632' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/472566157554628632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/472566157554628632'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/07/how-to-compile-command-line-utility-for.html' title='How to compile command line utility for iPhone using XCode gcc'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-1333638070396042157</id><published>2009-06-20T19:27:00.042+08:00</published><updated>2010-07-10T12:11:20.174+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Provisioning Profile'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><title type='text'>Use XCode 3.1.2 to build SDK 3.0 app to 3.0 Device without provisioning profile</title><content type='html'>The trick to skip Provisioning Profile for the new XCode 3.1.3 (iPhone SDK3.0) does not work now.  The only thing you can do is to use the old XCode 3.1.2 &amp;lt;Old XCode Dir&amp;gt; to build app for 3.0 device if you don't have the official provisioning profile, until new method to skip provisioning profile can be found.&lt;br /&gt;&lt;br /&gt;What you need is to install the new iPhone SDK 3.0 (XCode 3.1.3) in a new directory (non-default dir) &amp;lt;New XCode Dir&amp;gt; and copy the SDK3.0 and the necessary device support files to XCode 3.1.2 and use it build app to 3.0 device.&lt;br /&gt;&lt;br /&gt;You need to do the followings:&lt;br /&gt;&lt;br /&gt;(1) Create a symbolic link from &amp;lt;New XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk&lt;br /&gt;  to &amp;lt;Old XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/&lt;br /&gt;&lt;br /&gt;(2) Create a symbolic link from &amp;lt;New XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0 (7A341)&lt;br /&gt; to &amp;lt;Old XCode Dir&amp;gt;Developer/Platforms/iPhoneOS.platform/DeviceSupport/&lt;br /&gt;&lt;br /&gt;(3) Backup the folder of &amp;lt;Old XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Developer/usr&lt;br /&gt;&lt;br /&gt;(4) Replace the folder of &amp;lt;Old XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Developer/usr&lt;br /&gt;by &amp;lt;New XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Developer/usr&lt;br /&gt;&lt;br /&gt;(5) Edit the &amp;lt;Old XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Info.plist to have the magic keys, may be you have already done so.  You can refer to &lt;a href="http://iphonesdkdev.blogspot.com/2009/01/how-to-skip-provisioning-profile-for.html"&gt;this for instruction&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Info.plist:&lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=1333638070396042157#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;key&amp;gt;OverrideProperties&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;lt;dict&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;CODE_SIGN_CONTEXT_CLASS&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;XCiPhoneOSCodeSignContext&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;DEBUG_INFORMATION_FORMAT&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;dwarf-with-dsym&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;EMBEDDED_PROFILE_NAME&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;embedded.mobileprovision&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;SDKROOT&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;iphoneos2.2.1&amp;lt;/string&amp;gt;&lt;br /&gt; &lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&amp;lt;key&amp;gt;PROVISIONING_PROFILE_ALLOWED&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;NO&amp;lt;/string&amp;gt;&lt;br /&gt; &amp;lt;key&amp;gt;PROVISIONING_PROFILE_REQUIRED&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;string&amp;gt;NO&amp;lt;/string&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;/dict&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(6) Create a self signed identity say "iPhone Pwned Developer" in your Mac (you probably have this already) see &lt;a href="http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW1"&gt;Apple Guide here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(7) Remember to restart Xcode (your old Xcode 3.1.2)&lt;br /&gt;&lt;br /&gt;(8) Install the &lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;Installd Patch for OS 3.0&lt;/span&gt; to your 3.0 device.  This package is in Tweaks Section from the Cydia Source http://iphone.org.hk/apt/ which is released by me.  Please reboot device after installation of this package.&lt;br /&gt;&lt;br /&gt;(9) Create New Project in in XCode 3.1.2 and in Info.plist, add the magic key of SignerIdentity, you probably know this already. (update, you don't need this after installd patch and for OS 3.0 or above)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;key&amp;gt;SignerIdentity&amp;lt;/key&amp;gt;&lt;br /&gt;&amp;lt;string&amp;gt;Apple iPhone OS Application Signing&amp;lt;/string&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(10) Use the codesign identity as created in step 6 above to codesign the binary and Build and Go to 3.0 device&lt;br /&gt;&lt;br /&gt;P. S. I did not copy the Simulator SDK 3.0, because I can use the iPhone SDK 3.0 in &amp;lt;New XCode Dir&amp;gt; to test 3.0 Simulator.  If you want to update the documentation in your old XCode, it is in &amp;lt;New XCode Dir&amp;gt;/Developer/Platforms/iPhoneOS.platform/Developer/Documentation&lt;br /&gt;&lt;br /&gt;You can use move instead of symbolic link, if you want to uninstall the &amp;lt;New XCode Dir&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For those who wants to get the iPhone SDK 2.2.1 (XCode 3.1.2) , try the direct download link here (you need to login your developer account)&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 2.2.1 direct download link&lt;/u&gt;&lt;br /&gt;&lt;a href="http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_for_iphone_os_2.2.1__9m2621a__final/iphone_sdk_for_iphone_os_2.2.19m2621afinal.dmg"&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_for_iphone_os_2.2.1__9m2621a__final/iphone_sdk_for_iphone_os_2.2.19m2621afinal.dmg&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 2.2 direct download link&lt;/u&gt;&lt;br /&gt;&lt;a href="http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_for_iphone_os_2.2__9m2621__final/iphone_sdk_for_iphone_os_2.2_9m2621_final.dmg"&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_for_iphone_os_2.2__9m2621__final/iphone_sdk_for_iphone_os_2.2_9m2621_final.dmg&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.0 (Xcode 3.1.3) Leopard direct download link&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.0__final/iphone_sdk_3.0__leopard__9m2736__final.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.0 (Xcode 3.2) Snow Leopard direct download link&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.0__final/iphone_sdk_3.0__snow_leopard__final.dmg&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.1 with Xcode 3.1.4 Leopard direct download link&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1__final/iphone_sdk_3.1_with_xcode_3.1_final__leopard__9m2809.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.1 with XCode 3.2.1 for Snow Leopard&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1__final/iphone_sdk_3.1_with_xcode_3.2_final__snow_leopard__10a432.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.1.2 with XCode 3.1.4 for Leopard&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1.2__final/iphone_sdk_3.1.2_with_xcode_3.1.4__leopard__9m2809.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.1.2 with XCode 3.2.1 for Snow Leopard&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1.2__final/iphone_sdk_3.1.2_with_xcode_3.2.1__snow_leopard__10m2003.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.1.3 with XCode 3.1.4 for Leopard&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1.3__final/iphone_sdk_3.1.3_with_xcode_3.1.4__leopard__9m2809a.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.1.3 with XCode 3.2.1 for Snow Leopard&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.1.3__final/iphone_sdk_3.1.3_with_xcode_3.2.1__snow_leopard__10m2003a.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.2 beta 4 with Xcode 3.2.2 (Snow Leopard)&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.2_beta_4/iphone_sdk_3.2_beta_4_with_xcode_3.2.2.dmg&lt;br /&gt;&lt;br /&gt;&lt;u&gt;iPhone SDK 3.2 with Xcode 3.2.2 (Snow Leopard)&lt;/u&gt;&lt;br /&gt;http://developer.apple.com/iphone/download.action?path=/iphone/iphone_sdk_3.2__final/xcode_3.2.2_and_iphone_sdk_3.2_final.dmg&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;Updates: use this script to patch "iPhoneOS\ Build\ System\ Support".  If you think the use of dd utility is fragile, don't use it.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; patch.sh &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=1333638070396042157#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/&lt;br /&gt;&lt;br /&gt;dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255&lt;br /&gt;printf "\x8f\x2a\x00\x00" &gt;&gt; working&lt;br /&gt;dd if=iPhoneOS\ Build\ System\ Support of=working bs=1 skip=127504 seek=127504&lt;br /&gt;/bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original&lt;br /&gt;/bin/mv working iPhoneOS\ Build\ System\ Support&lt;br /&gt;chmod a+x iPhoneOS\ Build\ System\ Support&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-1333638070396042157?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/1333638070396042157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=1333638070396042157' title='48 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1333638070396042157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1333638070396042157'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/06/use-xcode-312-to-build-sdk-30-app-to-30.html' title='Use XCode 3.1.2 to build SDK 3.0 app to 3.0 Device without provisioning profile'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>48</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-9124976109393665075</id><published>2009-05-15T21:08:00.040+08:00</published><updated>2009-11-22T12:24:31.374+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OpenGL ES'/><title type='text'>OpenGL ES for iPhone : Part 4 with More Drawings and OpenGL Screen Save</title><content type='html'>In some OpenGL 1.x books you might notice that the gl commands (like belows) are within the code block of glBegin() and glEnd() pair.  These gl* commands must be converted to Vertices Array in order to be useful for OpenGL ES for iPhone.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;glBegin(GL_LINE_STRIP);&lt;br /&gt;z = -50.0f;&lt;br /&gt;for(angle = 0.0f; angle &lt;= (2.0f*GL_PI)*3.0f; angle += 0.1f)  {    x = 50.0f*sin(angle);    y = 50.0f*cos(angle);    // Specify the point and move the z value up a little    glVertex3f(x, y, z);    z += 0.5f;  }  // Done drawing points  glEnd();  &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Typically, you remove the glBegin() and glEnd() commands (that is immediate mode) and create the vertices array and implement the vertices position calculation (if any) inside the setupView and then remove other unsupported gl* commands before putting them to the iPhone OpenGL ES project code.&lt;br /&gt;&lt;br /&gt;This is an example converting from the immediate mode to vertex arrays&lt;br /&gt;&lt;br /&gt;&lt;b&gt;immediate mode&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;glBegin(GL_TRIANGLES);&lt;br /&gt;  glVertex3f(-2.0, 0.5, 0.0);&lt;br /&gt;  glVertex3f(0.0, 4.0, -2.0);&lt;br /&gt;  glVertex3f(1.5, 2.5, -0.5);&lt;br /&gt;glEnd();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;vertex arrays&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;GLfloat vertices[] = { -2.0, 0.5, 0.0, 0.0, 4.0, -2.0, 1.5, 2.5, -0.5 };&lt;br /&gt;glVertexPointer(3, GL_FLOAT, 0, vertices);&lt;br /&gt;glDrawArrays(GL_TRIANGLES, 0, 3);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;OpenGL ES does not support the full set of vertex array functions or parameters present in OpenGL&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;table  border=1 width=50%&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;Function&lt;/td&gt;&lt;td&gt;Notes&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glBegin()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glEnd()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glEdgeFlag[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glVertex{234}{sifd}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glNormal3f()&lt;/td&gt;&lt;td&gt;Supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glNormal3{bsifd}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glNormal3{bsifd}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glTexCoord{1234}{sifd}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glMultiTexCoord4f()&lt;/td&gt;&lt;td&gt;Supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glMultiTexCoord{1234}{sifd}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glColor4f()&lt;/td&gt;&lt;td&gt;Supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glColor{34}{bsifd ub us ui}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glIndex{sifd ub}[v]()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glVertexPointer()&lt;/td&gt;&lt;td&gt;Supported.&lt;br/&gt;Type cannot be GL_INT or GL_DOUBLE, but support for&lt;br/&gt;GL_BYTE has been added.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glNormalPointer()&lt;/td&gt;&lt;td&gt;Supported.&lt;br/&gt;Type cannot be GL_INT or GL_DOUBLE, but support for&lt;br/&gt;GL_BYTE has been added.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glColorPointer()&lt;/td&gt;&lt;td&gt;Supported.&lt;br/&gt;Type cannot be GL_INT or GL_DOUBLE, but&lt;br/&gt;support for GL_UNSIGNED_BYTE has been added. &lt;br/&gt;In addition, the alpha value must be included with all colors; &lt;br/&gt;there is no support for specifying only the RGB values.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glIndexPointer()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glTexCoordPointer()&lt;/td&gt;&lt;td&gt;Supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;Type cannot be GL_INT or GL_DOUBLE, but support&lt;br/&gt;for GL_BYTE has been added. Also, because there is no support&lt;br/&gt;for 1D textures, at least 2 texture coordinates must be provided&lt;br/&gt;per vertex.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glEdgeFlagPointer()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glInterleavedArrays()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glArrayElement()&lt;/td&gt;&lt;td&gt;Not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glDrawArrays()&lt;/td&gt;&lt;td&gt;GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLES,&lt;br/&gt;GL_TRIANGLE_STRIP, and GL_TRIANGLE_FAN are supported.&lt;br/&gt;GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON are not supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glDrawElements()&lt;/td&gt;&lt;td&gt;GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLES,&lt;br/&gt;GL_TRIANGLE_STRIP, and GL_TRIANGLE_FAN are supported.&lt;br/&gt;GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON are not&lt;br/&gt;supported. Type must either be GL_UNSIGNED_BYTE or&lt;br/&gt;GL_UNSIGNED_SHORT (not GL_UNSIGNED_INT).&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glDrawRangeElements()&lt;/td&gt;&lt;td&gt;Supported.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glEnableClientState()&lt;/td&gt;&lt;td&gt;Valid for all supported attributes.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;glDisableClientState()&lt;/td&gt;&lt;td&gt;Valid for all supported attributes.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here are some of the typical drawings in 3D.  This one is for a &lt;span style="font-weight: bold;"&gt;rotating Spiral&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sg1r8mam4JI/AAAAAAAAAvM/nqp19Qfkr8E/s1600-h/IMG_0015.JPG"&gt;&lt;img style="cursor: pointer; width: 267px; height: 400px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sg1r8mam4JI/AAAAAAAAAvM/nqp19Qfkr8E/s400/IMG_0015.JPG" alt="" id="BLOGGER_PHOTO_ID_5336039822352375954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To use the source codes here, you just need to create a new project from OpenGL ES Application template of XCode and copy the source codes of EAGLView.m from below and paste them for Build &amp;amp; Go in XCode.&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.m (for Spiral) &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=9124976109393665075#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//&lt;br /&gt;//  EAGLView.m&lt;br /&gt;//  Spiral&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#import &amp;lt;QuartzCore/QuartzCore.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGLDrawable.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#import "EAGLView.h"&lt;br /&gt;&lt;br /&gt;#define USE_DEPTH_BUFFER 0&lt;br /&gt;&lt;br /&gt;// A class extension to declare private methods&lt;br /&gt;@interface EAGLView ()&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) EAGLContext *context;&lt;br /&gt;@property (nonatomic, assign) NSTimer *animationTimer;&lt;br /&gt;&lt;br /&gt;- (BOOL) createFramebuffer;&lt;br /&gt;- (void) destroyFramebuffer;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@implementation EAGLView&lt;br /&gt;&lt;br /&gt;@synthesize context;&lt;br /&gt;@synthesize animationTimer;&lt;br /&gt;@synthesize animationInterval;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// You must implement this method&lt;br /&gt;+ (Class)layerClass {&lt;br /&gt;   return [CAEAGLLayer class];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#define kAnimationFrequency 60.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:&lt;br /&gt;- (id)initWithCoder:(NSCoder*)coder {&lt;br /&gt;  &lt;br /&gt;   if ((self = [super initWithCoder:coder])) {&lt;br /&gt;       // Get the layer&lt;br /&gt;       CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;&lt;br /&gt;      &lt;br /&gt;       eaglLayer.opaque = YES;&lt;br /&gt;       eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:&lt;br /&gt;                                       [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];&lt;br /&gt;      &lt;br /&gt;       context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];&lt;br /&gt;      &lt;br /&gt;       if (!context || ![EAGLContext setCurrentContext:context]) {&lt;br /&gt;           [self release];&lt;br /&gt;           return nil;&lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;       animationInterval = 1.0 / kAnimationFrequency;&lt;br /&gt; [self setupView];&lt;br /&gt;   }&lt;br /&gt;   return self;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#define GL_PI 3.1415f&lt;br /&gt;GLfloat linesVertices[186];&lt;br /&gt;&lt;br /&gt;- (void)setupView {&lt;br /&gt;&lt;br /&gt;// setup the projection matrix&lt;br /&gt;glMatrixMode(GL_PROJECTION);&lt;br /&gt;glLoadIdentity();&lt;br /&gt;&lt;br /&gt;//glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);&lt;br /&gt;GLfloat nRange = 100.0f;&lt;br /&gt;GLfloat w = 320.0f, h = 480.0f;&lt;br /&gt;glOrthof (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);&lt;br /&gt;&lt;br /&gt;glMatrixMode(GL_MODELVIEW);&lt;br /&gt;&lt;br /&gt;GLfloat x,y,z,angle; // Storage for coordinates and angles&lt;br /&gt;int c = 0;&lt;br /&gt;z = -50.0f;&lt;br /&gt;&lt;br /&gt;// Loop around in a circle three times&lt;br /&gt;for(angle = 0.0f; angle &lt;= (2.0f*GL_PI)*3.0f; angle += 0.1f)   {   // Calculate x and y values on the circle    x = 50.0f*sin(angle);    y = 50.0f*cos(angle);  //  glVertex3f(x, y, z);   linesVertices[c++] = x;    linesVertices[c++] = y;    linesVertices[c++] = z;       // Bump up the z value   z += 0.5f;  } }  - (void)drawView {         static GLfloat xRot = 0.0f;  static GLfloat yRot = 0.0f;  static GLfloat zRot = 1.0f;        const GLubyte linesColors[] = {         0.0f,  0.0f,   0.0f, 1.0f,     };      [EAGLContext setCurrentContext:context];     glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);     glViewport(0, 0, backingWidth, backingHeight);    // Clear background color     glClearColor(0.5f, 0.5f, 0.5f, 1.0f);     glClear(GL_COLOR_BUFFER_BIT);    glRotatef(xRot, 0.0f, 0.0f, 0.0f);   glRotatef(yRot, 1.0f, 1.0f, 0.0f);   glRotatef(zRot, 0.0f, 0.0f, 1.0f);          // Set Line Width   glLineWidth(3.0f);      glVertexPointer(3, GL_FLOAT, 0, linesVertices);   // Set drawing color to green  glColor4f(0.0f, 1.0f, 0.0f, 0.0f);  glColorPointer(4, GL_UNSIGNED_BYTE, 0, linesColors);  glEnableClientState(GL_VERTEX_ARRAY);      glDrawArrays(GL_LINES, 0, 189);       glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);     [context presentRenderbuffer:GL_RENDERBUFFER_OES];   static NSTimeInterval lastDrawTime;     if (lastDrawTime)     {         NSTimeInterval timeSinceLastDraw = [NSDate timeIntervalSinceReferenceDate] - lastDrawTime;         xRot += 0.1 * timeSinceLastDraw;     }     lastDrawTime = [NSDate timeIntervalSinceReferenceDate];  }   - (void)layoutSubviews {     [EAGLContext setCurrentContext:context];     [self destroyFramebuffer];     [self createFramebuffer];     [self drawView]; }   - (BOOL)createFramebuffer {          glGenFramebuffersOES(1, &amp;amp;viewFramebuffer);     glGenRenderbuffersOES(1, &amp;amp;viewRenderbuffer);          glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);     glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);     [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];     glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);          glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;amp;backingWidth);     glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;amp;backingHeight);          if (USE_DEPTH_BUFFER) {         glGenRenderbuffersOES(1, &amp;amp;depthRenderbuffer);         glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);         glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);         glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);     }          if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {         NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));         return NO;     }          return YES; }   - (void)destroyFramebuffer {          glDeleteFramebuffersOES(1, &amp;amp;viewFramebuffer);     viewFramebuffer = 0;     glDeleteRenderbuffersOES(1, &amp;amp;viewRenderbuffer);     viewRenderbuffer = 0;          if(depthRenderbuffer) {         glDeleteRenderbuffersOES(1, &amp;amp;depthRenderbuffer);         depthRenderbuffer = 0;     } }   - (void)startAnimation {     self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; }   - (void)stopAnimation {     self.animationTimer = nil; }   - (void)setAnimationTimer:(NSTimer *)newTimer {     [animationTimer invalidate];     animationTimer = newTimer; }   - (void)setAnimationInterval:(NSTimeInterval)interval {          animationInterval = interval;     if (animationTimer) {         [self stopAnimation];         [self startAnimation];     } }   - (void)dealloc {          [self stopAnimation];          if ([EAGLContext currentContext] == context) {         [EAGLContext setCurrentContext:nil];     }          [context release];       [super dealloc]; }  @end &lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;And this one is for a rotating &lt;span style="font-weight: bold;"&gt;Fanned Circle&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sg1sUjo9J1I/AAAAAAAAAvU/2fw1bpJeFgc/s1600-h/IMG_0016.JPG"&gt;&lt;img style="cursor: pointer; width: 267px; height: 400px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sg1sUjo9J1I/AAAAAAAAAvU/2fw1bpJeFgc/s400/IMG_0016.JPG" alt="" id="BLOGGER_PHOTO_ID_5336040233924110162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.m (Fanned Circle) &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=9124976109393665075#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//&lt;br /&gt;//  EAGLView.m&lt;br /&gt;//  Fanned Circle&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#import &amp;lt;QuartzCore/QuartzCore.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGLDrawable.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#import "EAGLView.h"&lt;br /&gt;&lt;br /&gt;#define USE_DEPTH_BUFFER 0&lt;br /&gt;&lt;br /&gt;// A class extension to declare private methods&lt;br /&gt;@interface EAGLView ()&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) EAGLContext *context;&lt;br /&gt;@property (nonatomic, assign) NSTimer *animationTimer;&lt;br /&gt;&lt;br /&gt;- (BOOL) createFramebuffer;&lt;br /&gt;- (void) destroyFramebuffer;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@implementation EAGLView&lt;br /&gt;&lt;br /&gt;@synthesize context;&lt;br /&gt;@synthesize animationTimer;&lt;br /&gt;@synthesize animationInterval;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// You must implement this method&lt;br /&gt;+ (Class)layerClass {&lt;br /&gt;   return [CAEAGLLayer class];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#define kAnimationFrequency 60.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:&lt;br /&gt;- (id)initWithCoder:(NSCoder*)coder {&lt;br /&gt;  &lt;br /&gt;   if ((self = [super initWithCoder:coder])) {&lt;br /&gt;       // Get the layer&lt;br /&gt;       CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;&lt;br /&gt;      &lt;br /&gt;       eaglLayer.opaque = YES;&lt;br /&gt;       eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:&lt;br /&gt;                                       [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];&lt;br /&gt;      &lt;br /&gt;       context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];&lt;br /&gt;      &lt;br /&gt;       if (!context || ![EAGLContext setCurrentContext:context]) {&lt;br /&gt;           [self release];&lt;br /&gt;           return nil;&lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;       animationInterval = 1.0 / kAnimationFrequency;&lt;br /&gt; [self setupView];&lt;br /&gt;   }&lt;br /&gt;   return self;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#define GL_PI 3.1415f&lt;br /&gt;GLfloat linesVertices[186];&lt;br /&gt;&lt;br /&gt;- (void)setupView {&lt;br /&gt;&lt;br /&gt;// setup the projection matrix&lt;br /&gt;glMatrixMode(GL_PROJECTION);&lt;br /&gt;glLoadIdentity();&lt;br /&gt;&lt;br /&gt;//glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);&lt;br /&gt;GLfloat nRange = 100.0f;&lt;br /&gt;GLfloat w = 320.0f, h = 480.0f;&lt;br /&gt;glOrthof (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;glMatrixMode(GL_MODELVIEW);&lt;br /&gt;&lt;br /&gt;GLfloat x,y,z,angle; // Storage for coordinates and angles&lt;br /&gt;int c;&lt;br /&gt;z = 0.0f;&lt;br /&gt;c = 0;&lt;br /&gt;for(angle = 0.0f; angle &lt;= GL_PI; angle += (GL_PI / 20.0f))  {   // Top half of the circle   x = 50.0f*sin(angle);   y = 50.0f*cos(angle); //  glVertex3f(x, y, z);   linesVertices[c++] = x;    linesVertices[c++] = y;    linesVertices[c++] = z;       // Bottom half of the circle   x = 50.0f*sin(angle+GL_PI);   y = 50.0f*cos(angle+GL_PI); //  glVertex3f(x, y, z);    linesVertices[c++] = x;    linesVertices[c++] = y;    linesVertices[c++] = z;   }  }  - (void)drawView {         static GLfloat xRot = 0.0f;  static GLfloat yRot = 0.0f;  static GLfloat zRot = 1.0f;        const GLubyte linesColors[] = {         0.0f,  1.0f,   0.0f, 1.0f,     };    [EAGLContext setCurrentContext:context];     glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);     glViewport(0, 0, backingWidth, backingHeight);    // Clear background color     glClearColor(0.5f, 0.5f, 0.5f, 1.0f);     glClear(GL_COLOR_BUFFER_BIT);    glRotatef(xRot, 1.0f, 0.0f, 0.0f);   glRotatef(yRot, 0.0f, 1.0f, 0.0f);   glRotatef(zRot, 0.0f, 0.0f, 1.0f);        // Setup and render the points     glEnable(GL_POINT_SMOOTH);     glPointSize(1.0);     glVertexPointer(3, GL_FLOAT, 0, linesVertices);  // Set drawing color to green  glColor4f(0.0f, 1.0f, 0.0f, 0.0f);  glColorPointer(4, GL_UNSIGNED_BYTE, 0, linesColors);  glEnableClientState(GL_VERTEX_ARRAY);      glDrawArrays(GL_LINES, 0, 189);       glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);     [context presentRenderbuffer:GL_RENDERBUFFER_OES];   static NSTimeInterval lastDrawTime;     if (lastDrawTime)     {         NSTimeInterval timeSinceLastDraw = [NSDate timeIntervalSinceReferenceDate] - lastDrawTime;         zRot+=1.2 * timeSinceLastDraw;     }     lastDrawTime = [NSDate timeIntervalSinceReferenceDate];  }   - (void)layoutSubviews {     [EAGLContext setCurrentContext:context];     [self destroyFramebuffer];     [self createFramebuffer];     [self drawView]; }   - (BOOL)createFramebuffer {          glGenFramebuffersOES(1, &amp;amp;viewFramebuffer);     glGenRenderbuffersOES(1, &amp;amp;viewRenderbuffer);          glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);     glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);     [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];     glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);          glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;amp;backingWidth);     glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;amp;backingHeight);          if (USE_DEPTH_BUFFER) {         glGenRenderbuffersOES(1, &amp;amp;depthRenderbuffer);         glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);         glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);         glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);     }          if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {         NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));         return NO;     }          return YES; }   - (void)destroyFramebuffer {          glDeleteFramebuffersOES(1, &amp;amp;viewFramebuffer);     viewFramebuffer = 0;     glDeleteRenderbuffersOES(1, &amp;amp;viewRenderbuffer);     viewRenderbuffer = 0;          if(depthRenderbuffer) {         glDeleteRenderbuffersOES(1, &amp;amp;depthRenderbuffer);         depthRenderbuffer = 0;     } }   - (void)startAnimation {     self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; }   - (void)stopAnimation {     self.animationTimer = nil; }   - (void)setAnimationTimer:(NSTimer *)newTimer {     [animationTimer invalidate];     animationTimer = newTimer; }   - (void)setAnimationInterval:(NSTimeInterval)interval {          animationInterval = interval;     if (animationTimer) {         [self stopAnimation];         [self startAnimation];     } }   - (void)dealloc {          [self stopAnimation];          if ([EAGLContext currentContext] == context) {         [EAGLContext setCurrentContext:nil];     }          [context release];       [super dealloc]; }  @end &lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;And also I have found a very nice method &lt;span style="font-weight: bold;"&gt;saveCurrentScreenToPhotoAlbum&lt;/span&gt; to capture the OpenGL view screen &lt;a href="http://www.bit-101.com/blog/?p=1861"&gt;here&lt;/a&gt;.  And below is an implementation on how to capture the screen in iPhone Simulator.  You just touch/click the info button at the lower left bottom of iPhone Screen to trigger the screen capture to the Photo Album (Simulator or actual device).&lt;br /&gt;&lt;br /&gt;To use the source codes here, you just need to create a new project from OpenGL ES Application template of XCode and copy the source codes of EAGLView.m from below and paste them for Build &amp;amp; Go in XCode.  For this screenshot functionality, you need to add the &lt;span style="font-style: italic;"&gt;CoreGraphics Framework&lt;/span&gt; to the Xcode Project before build &amp;amp; go.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3LRNVfBfliQ/Sg1umu2zhwI/AAAAAAAAAvc/rGVmzXIL7ZU/s1600-h/fannedcircle.png"&gt;&lt;img style="cursor: pointer; width: 215px; height: 400px;" src="http://1.bp.blogspot.com/_3LRNVfBfliQ/Sg1umu2zhwI/AAAAAAAAAvc/rGVmzXIL7ZU/s400/fannedcircle.png" alt="" id="BLOGGER_PHOTO_ID_5336042745195890434" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.m (Fanned Circle with Screen Capture) &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=9124976109393665075#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//&lt;br /&gt;//  EAGLView.m&lt;br /&gt;//  Fanned Circle with Screen Capture&lt;br /&gt;//&lt;br /&gt;#import &amp;lt;QuartzCore/QuartzCore.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGLDrawable.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#import "EAGLView.h"&lt;br /&gt;&lt;br /&gt;#define USE_DEPTH_BUFFER 0&lt;br /&gt;&lt;br /&gt;// A class extension to declare private methods&lt;br /&gt;@interface EAGLView ()&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) EAGLContext *context;&lt;br /&gt;@property (nonatomic, assign) NSTimer *animationTimer;&lt;br /&gt;&lt;br /&gt;- (BOOL) createFramebuffer;&lt;br /&gt;- (void) destroyFramebuffer;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@implementation EAGLView&lt;br /&gt;&lt;br /&gt;@synthesize context;&lt;br /&gt;@synthesize animationTimer;&lt;br /&gt;@synthesize animationInterval;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// You must implement this method&lt;br /&gt;+ (Class)layerClass {&lt;br /&gt;   return [CAEAGLLayer class];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#define kAnimationFrequency 60.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:&lt;br /&gt;- (id)initWithCoder:(NSCoder*)coder {&lt;br /&gt;  &lt;br /&gt;   if ((self = [super initWithCoder:coder])) {&lt;br /&gt;       // Get the layer&lt;br /&gt;       CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;&lt;br /&gt;      &lt;br /&gt;       eaglLayer.opaque = YES;&lt;br /&gt;       eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:&lt;br /&gt;                                       [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];&lt;br /&gt;      &lt;br /&gt;       context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];&lt;br /&gt;      &lt;br /&gt;       if (!context || ![EAGLContext setCurrentContext:context]) {&lt;br /&gt;           [self release];&lt;br /&gt;           return nil;&lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;       animationInterval = 1.0 / kAnimationFrequency;&lt;br /&gt; [self setupView];&lt;br /&gt;   }&lt;br /&gt;   return self;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#define GL_PI 3.1415f&lt;br /&gt;GLfloat linesVertices[186];&lt;br /&gt;&lt;br /&gt;- (void)setupView {&lt;br /&gt;&lt;br /&gt;UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];&lt;br /&gt;[infoButton addTarget:self action:@selector(saveCurrentScreenToPhotoAlbum) forControlEvents:UIControlEventTouchUpInside];&lt;br /&gt;infoButton.alpha = 0.5f;&lt;br /&gt;infoButton.frame = CGRectMake(17, self.bounds.size.height-33, 33, 33);&lt;br /&gt;[self addSubview:infoButton];&lt;br /&gt;[self bringSubviewToFront:infoButton];&lt;br /&gt;&lt;br /&gt;// setup the projection matrix&lt;br /&gt;glMatrixMode(GL_PROJECTION);&lt;br /&gt;glLoadIdentity();&lt;br /&gt;&lt;br /&gt;//glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);&lt;br /&gt;GLfloat nRange = 100.0f;&lt;br /&gt;GLfloat w = 320.0f, h = 480.0f;&lt;br /&gt;glOrthof (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;glMatrixMode(GL_MODELVIEW);&lt;br /&gt;&lt;br /&gt;GLfloat x,y,z,angle; // Storage for coordinates and angles&lt;br /&gt;int c;&lt;br /&gt;z = 0.0f;&lt;br /&gt;c = 0;&lt;br /&gt;for(angle = 0.0f; angle &lt;= GL_PI; angle += (GL_PI / 20.0f))  {   // Top half of the circle   x = 50.0f*sin(angle);   y = 50.0f*cos(angle); //  glVertex3f(x, y, z);   linesVertices[c++] = x;    linesVertices[c++] = y;    linesVertices[c++] = z;       // Bottom half of the circle   x = 50.0f*sin(angle+GL_PI);   y = 50.0f*cos(angle+GL_PI); //  glVertex3f(x, y, z);    linesVertices[c++] = x;    linesVertices[c++] = y;    linesVertices[c++] = z;   }   }  - (void)drawView {         static GLfloat xRot = 0.0f;  static GLfloat yRot = 0.0f;  static GLfloat zRot = 1.0f;        const GLubyte linesColors[] = {         0.0f,  1.0f,   0.0f, 1.0f,     };    [EAGLContext setCurrentContext:context];     glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);     glViewport(0, 0, backingWidth, backingHeight);    // Clear background color     glClearColor(0.5f, 0.5f, 0.5f, 1.0f);     glClear(GL_COLOR_BUFFER_BIT);    glRotatef(xRot, 1.0f, 0.0f, 0.0f);   glRotatef(yRot, 0.0f, 1.0f, 0.0f);   glRotatef(zRot, 0.0f, 0.0f, 1.0f);        // Setup and render the points     glEnable(GL_POINT_SMOOTH);     glPointSize(1.0);     glVertexPointer(3, GL_FLOAT, 0, linesVertices);  // Set drawing color to green  glColor4f(0.0f, 1.0f, 0.0f, 0.0f);  glColorPointer(4, GL_UNSIGNED_BYTE, 0, linesColors);  glEnableClientState(GL_VERTEX_ARRAY);      glDrawArrays(GL_LINES, 0, 189);       glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);     [context presentRenderbuffer:GL_RENDERBUFFER_OES];   static NSTimeInterval lastDrawTime;     if (lastDrawTime)     {         NSTimeInterval timeSinceLastDraw = [NSDate timeIntervalSinceReferenceDate] - lastDrawTime;         zRot+=0.1 * timeSinceLastDraw;     }     lastDrawTime = [NSDate timeIntervalSinceReferenceDate];  }  // callback for CGDataProviderCreateWithData void releaseScreenshotData(void *info, const void *data, size_t size) {  free((void *)data); };  // callback for UIImageWriteToSavedPhotosAlbum - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {  NSLog(@"ScreenSave finished\n");  [image release];  // release image }  - (void)saveCurrentScreenToPhotoAlbum {  NSInteger myDataLength = backingWidth * backingHeight * 4;  // allocate array and read pixels into it.  GLuint *buffer = (GLuint *) malloc(myDataLength);  glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);  // gl renders “upside down” so swap top to bottom into new array.  for(int y = 0; y &lt; x =" 0;" top =" buffer[y" bottom =" buffer[(backingHeight" provider =" CGDataProviderCreateWithData(NULL," bitspercomponent =" 8;" bitsperpixel =" 4" bytesperrow =" 4" colorspaceref =" CGColorSpaceCreateDeviceRGB();" bitmapinfo =" kCGBitmapByteOrderDefault;" renderingintent =" kCGRenderingIntentDefault;" imageref =" CGImageCreate(320," myimage =" [[UIImage" viewframebuffer =" 0;" viewrenderbuffer =" 0;" depthrenderbuffer =" 0;" animationtimer =" [NSTimer" animationtimer =" nil;" animationtimer =" newTimer;" animationinterval =" interval;"&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;In case you might also want to know how to do screenshot for a non-OpenGL ES content programatically.  This is the code for viewcontroller.  If you put the code in a UIView object change &lt;span style="font-style: italic;"&gt;self.view&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;self&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;- (void) snapUIView&lt;br /&gt;{&lt;br /&gt;    UIGraphicsBeginImageContext(self.view.bounds.size);&lt;br /&gt;    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];&lt;br /&gt;    UIImage *myImage = UIGraphicsGetImageFromCurrentImageContext();&lt;br /&gt;    UIGraphicsEndImageContext();&lt;br /&gt;    UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-9124976109393665075?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/9124976109393665075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=9124976109393665075' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/9124976109393665075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/9124976109393665075'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/05/opengl-es-for-iphone-part-4-with-more.html' title='OpenGL ES for iPhone : Part 4 with More Drawings and OpenGL Screen Save'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_3LRNVfBfliQ/Sg1r8mam4JI/AAAAAAAAAvM/nqp19Qfkr8E/s72-c/IMG_0015.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-8069961641134479251</id><published>2009-05-13T14:11:00.013+08:00</published><updated>2009-09-27T22:56:14.266+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='class-dump'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='toolchain'/><title type='text'>How to classdump SpringBoard header files and patch it</title><content type='html'>To classdump the SpringBoard header,&lt;br /&gt;&lt;br /&gt;&lt;code&gt;class-dump-x /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/CoreServices/SpringBoard.app/SpringBoard -H -o Springboard&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;class-dump-x is available in Mac OS X and iPhone &lt;a href="http://iphone.freecoder.org/classdump_en.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;class-dumped header files are not directly usable and you should use this patch script to change the import statement of the dumped header files.&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; springboardheaderpatch.sh &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#/bin/sh&lt;br /&gt;cd SpringBoard&lt;br /&gt;perl -w -i -p -e "s/#import \"ISDownload.h\"/#import \&amp;lt;iTunesStore\/ISDownload.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"ISNetworkMonitor-Protocol.h\"/#import \&amp;lt;iTunesStore\/ISNetworkMonitor-Protocol.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSArray.h\"/#import \&amp;lt;Foundation\/NSArray.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSCharacterSet.h\"/#import \&amp;lt;Foundation\/NSCharacterSet.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSDictionary.h\"/#import \&amp;lt;Foundation\/NSDictionary.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSMutableArray.h\"/#import \&amp;lt;Foundation\/NSMutableArray.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSObject.h\"/#import \&amp;lt;Foundation\/NSObject.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSObject-Protocol.h\"/#import \&amp;lt;Foundation\/NSObject-Protocol.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSOperation.h\"/#import \&amp;lt;Foundation\/NSOperation.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSString.h\"/#import \&amp;lt;Foundation\/NSString.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"NSUserDefaults.h\"/#import \&amp;lt;Foundation\/NSUserDefaults.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBAlert.h\"/#import \&amp;lt;SpringBoard\/SBAlert.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBAlertDisplay.h\"/#import \&amp;lt;SpringBoard\/SBAlertDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBAlertInputView.h\"/#import \&amp;lt;SpringBoard\/SBAlertInputView.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBAlertItem.h\"/#import \&amp;lt;SpringBoard\/SBAlertItem.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBAlertWindow.h\"/#import \&amp;lt;SpringBoard\/SBAlertWindow.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBApplication.h\"/#import \&amp;lt;SpringBoard\/SBApplication.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBApplicationIcon.h\"/#import \&amp;lt;SpringBoard\/SBApplicationIcon.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBCallAlertDisplay.h\"/#import \&amp;lt;SpringBoard\/SBCallAlertDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBDismissOnlyAlertItem.h\"/#import \&amp;lt;SpringBoard\/SBDismissOnlyAlertItem.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBDisplay.h\"/#import \&amp;lt;SpringBoard\/SBDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBIcon.h\"/#import \&amp;lt;SpringBoard\/SBIcon.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBIconList.h\"/#import \&amp;lt;SpringBoard\/SBIconList.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBPhoneAlertItem.h\"/#import \&amp;lt;SpringBoard\/SBPhoneAlertItem.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBPlatformController.h\"/#import \&amp;lt;SpringBoard\/SBPlatformController.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBRingingAlertItem.h\"/#import \&amp;lt;SpringBoard\/SBRingingAlertItem.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBSIMLockEntryAlertDisplay.h\"/#import \&amp;lt;SpringBoard\/SBSIMLockEntryAlertDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBSIMToolkitAlert.h\"/#import \&amp;lt;SpringBoard\/SBSIMToolkitAlert.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBSIMToolkitGetInputDisplay.h\"/#import \&amp;lt;SpringBoard\/SBSIMToolkitGetInputDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBSIMToolkitTextAlertDisplay.h\"/#import \&amp;lt;SpringBoard\/SBSIMToolkitTextAlertDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBSlidingAlertDisplay.h\"/#import \&amp;lt;SpringBoard\/SBSlidingAlertDisplay.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBSoundPreferences.h\"/#import \&amp;lt;SpringBoard\/SBSoundPreferences.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBStatusBarContentView.h\"/#import \&amp;lt;SpringBoard\/SBStatusBarContentView.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBStatusBarInCallView.h\"/#import \&amp;lt;SpringBoard\/SBStatusBarInCallView.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBTVOutController.h\"/#import \&amp;lt;SpringBoard\/SBTVOutController.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SBUSSDAlert.h\"/#import \&amp;lt;SpringBoard\/SBUSSDAlert.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"SpringBoard.h\"/#import \&amp;lt;SpringBoard\/SpringBoard.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"TPPhonePad.h\"/#import \&amp;lt;TelephonyUI\/TPPhonePad.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIAlertSheetTableCell.h\"/#import \&amp;lt;UIKit\/UIAlertSheetTableCell.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIApplication.h\"/#import \&amp;lt;UIKit\/UIApplication.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIControl.h\"/#import \&amp;lt;UIKit\/UIControl.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIImageView.h\"/#import \&amp;lt;UIKit\/UIImageView.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIModalView.h\"/#import \&amp;lt;UIKit\/UIModalView.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIModalViewDelegate-Protocol.h\"/#import \&amp;lt;UIKit\/UIModalViewDelegate-Protocol.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIPageControl.h\"/#import \&amp;lt;UIKit\/UIPageControl.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIPasscodeField.h\"/#import \&amp;lt;UIKit\/UIPasscodeField.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIPreferencesTableCell.h\"/#import \&amp;lt;UIKit\/UIPreferencesTableCell.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIPushButton.h\"/#import \&amp;lt;UIKit\/UIPushButton.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIScroller.h\"/#import \&amp;lt;UIKit\/UIScroller.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UITextField.h\"/#import \&amp;lt;UIKit\/UITextField.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UITextFieldDelegate-Protocol.h\"/#import \&amp;lt;UIKit\/UITextFieldDelegate-Protocol.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIView.h\"/#import \&amp;lt;UIKit\/UIView.h\&amp;gt;/g" *.h&lt;br /&gt;perl -w -i -p -e "s/#import \"UIWindow.h\"/#import \&amp;lt;UIKit\/UIWindow.h\&amp;gt;/g" *.h&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is another version that will dump and patch the 3.0 SDK SpringBoard headers using sed instead of perl&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; springboard30.sh &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#/bin/sh&lt;br /&gt;SDKVER=3.0&lt;br /&gt;rm -f pringBoard/* SpringBoard/*&lt;br /&gt;class-dump-x /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/System/Library/CoreServices/SpringBoard.app/SpringBoard -H -o pringBoard&lt;br /&gt;mkdir -p SpringBoard&lt;br /&gt;for i in pringBoard/*.h&lt;br /&gt;do&lt;br /&gt;  sed "s/\(#import \)\"\(NS.*\.h\)\"/\1\&amp;lt;Foundation\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(UI.*\.h\)\"/\1\&amp;lt;UIKit\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(IS.*\.h\)\"/\1\&amp;lt;iTunesStore\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(SB.*\.h\)\"/\1\&amp;lt;SpringBoard\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(TP.*\.h\)\"/\1\&amp;lt;TelephonyUI\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(SpringBoard.*\.h\)\"/\1\&amp;lt;SpringBoard\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(SPDaemon.*\.h\)\"/\1\&amp;lt;SpringBoard\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(VS.*\.h\)\"/\1\&amp;lt;VoiceServices\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(APS.*\.h\)\"/\1\&amp;lt;ApplePushService\/\2\&amp;gt;/g" $i &gt; S$i&lt;br /&gt;done&lt;br /&gt;grep "import \".*h\"" SpringBoard/*.h&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;class dump and patch the 3.0 SDK UIKit headers using sed in iPhone&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; uikit30.sh &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#/bin/sh&lt;br /&gt;class-dump /System/Library/Frameworks/UIKit.framework/UIKit -H -o IKit&lt;br /&gt;mkdir -p UIKit&lt;br /&gt;for i in IKit/*.h&lt;br /&gt;do&lt;br /&gt;  sed "s/\(#import \)\"\(NS.*\.h\)\"/\1\&amp;lt;Foundation\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(UI.*\.h\)\"/\1\&amp;lt;UIKit\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(IS.*\.h\)\"/\1\&amp;lt;iTunesStore\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(SB.*\.h\)\"/\1\&amp;lt;SpringBoard\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(TP.*\.h\)\"/\1\&amp;lt;TelephonyUI\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(SpringBoard.*\.h\)\"/\1\&amp;lt;SpringBoard\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(SPDaemon.*\.h\)\"/\1\&amp;lt;SpringBoard\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(VS.*\.h\)\"/\1\&amp;lt;VoiceServices\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(APS.*\.h\)\"/\1\&amp;lt;ApplePushService\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(WebView.*\.h\)\"/\1\&amp;lt;WebKit\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(WebFrame.*\.h\)\"/\1\&amp;lt;WebKit\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(CA.*ayer.*\.h\)\"/\1\&amp;lt;QuartzCore\/\2\&amp;gt;/g;"\&lt;br /&gt;"s/\(#import \)\"\(DOM.*\.h\)\"/\1\&amp;lt;WebKit\/\2\&amp;gt;/g" $i &amp;gt; U$i&lt;br /&gt;done&lt;br /&gt;grep "import \".*h\"" UIKit/*.h&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-8069961641134479251?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/8069961641134479251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=8069961641134479251' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8069961641134479251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8069961641134479251'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/05/how-to-classdump-springboard-header.html' title='How to classdump SpringBoard header files and patch it'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2711150488733743904</id><published>2009-05-02T10:05:00.006+08:00</published><updated>2009-05-02T10:15:13.230+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><title type='text'>XCode GCC section missing in build settings</title><content type='html'>If you encounter this that the GCC 4 section was missing in XCode&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SfurVRf9e0I/AAAAAAAAAuU/GP_P831sPjk/s1600-h/gccmiss1.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 385px; height: 400px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SfurVRf9e0I/AAAAAAAAAuU/GP_P831sPjk/s400/gccmiss1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5331042965886171970" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All you need to do is to set the Active SDK to the same value as the Project Base SDK&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sfur5GE-qHI/AAAAAAAAAuc/J0Ke1YJjchE/s1600-h/gccmiss2.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 335px; height: 400px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sfur5GE-qHI/AAAAAAAAAuc/J0Ke1YJjchE/s400/gccmiss2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5331043581295503474" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Then you will see the GCC section again.&lt;br /&gt;&lt;br /&gt;But it will disappear when you set it to Simulator again, this is a bug.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SfusMy1_F3I/AAAAAAAAAuk/YTg0nhny3WU/s1600-h/gccmiss3.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 385px; height: 400px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SfusMy1_F3I/AAAAAAAAAuk/YTg0nhny3WU/s400/gccmiss3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5331043919729727346" /&gt;&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2711150488733743904?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2711150488733743904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2711150488733743904' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2711150488733743904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2711150488733743904'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/05/xcode-gcc-section-missing-in-build.html' title='XCode GCC section missing in build settings'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_3LRNVfBfliQ/SfurVRf9e0I/AAAAAAAAAuU/GP_P831sPjk/s72-c/gccmiss1.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-1504842176404267712</id><published>2009-04-15T07:48:00.006+08:00</published><updated>2009-04-15T10:08:16.768+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='Push Notification Service'/><title type='text'>APNS : Pushing tweets to iPhone</title><content type='html'>see here :&lt;br /&gt;&lt;a href="http://arstechnica.com/apple/guides/2009/04/pushing-tweets-to-your-iphone-with-apple-push-notifications.ars"&gt;http://arstechnica.com/apple/guides/2009/04/pushing-tweets-to-your-iphone-with-apple-push-notifications.ars&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can modify it to get the RSS feed as well. see code sample here&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; pushtweet.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt; while (1 &amp;gt; 0)&lt;br /&gt; {&lt;br /&gt; &lt;br /&gt;  TreeNode *root = [[XMLParser sharedInstance] parseXMLFromURL: [NSURL URLWithString:URL_STRING]];&lt;br /&gt;  TreeNode *found = nil;&lt;br /&gt;  for (TreeNode *node in [root children])&lt;br /&gt;  {&lt;br /&gt;   if (![[node key] isEqualToString:@"channel"]) continue;&lt;br /&gt;   if ([[node key] isEqualToString:@"channel"])&lt;br /&gt;   {&lt;br /&gt;    found = nil;&lt;br /&gt;    for (TreeNode *node2 in [node children]) {&lt;br /&gt;//     [node2 dump];&lt;br /&gt;     if ([[node2 key] isEqualToString:@"item"]) {&lt;br /&gt;      found = node2;&lt;br /&gt;      break;&lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;    if (found) break;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  if (found)&lt;br /&gt;  {&lt;br /&gt;   NSString *testString = [NSString stringWithFormat:@"%@:%@", [found leafForKey:@"title"], [found leafForKey:@"link"]];&lt;br /&gt;   NSString *prevString = [NSString stringWithContentsOfFile:TWEET_FILE encoding:NSUTF8StringEncoding error:nil];&lt;br /&gt;   if (![prevString isEqualToString:testString])&lt;br /&gt;   {&lt;br /&gt;    // Update with the new tweet information&lt;br /&gt;    NSLog(@"\nNew RSS title from %@:\n   \"%@\"\n\"%@\"\n", [found leafForKey:@"title"], [[found leafForKey:@"description"] substringToIndex:30], [found leafForKey:@"link"]);&lt;br /&gt;    &lt;br /&gt;    // Save the unmessed tweet to the ~/.tweet file&lt;br /&gt;    [testString writeToFile:TWEET_FILE atomically:YES encoding:NSUTF8StringEncoding error:nil];&lt;br /&gt;    &lt;br /&gt;    // handle reserved stuff. There's got to be a better way to escape&lt;br /&gt;    testString = [testString stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];&lt;br /&gt;    testString = [testString stringByReplacingOccurrencesOfString:@"'" withString:@""];&lt;br /&gt;    testString = [testString stringByReplacingOccurrencesOfString:@":" withString:@"-"];&lt;br /&gt;    testString = [testString stringByReplacingOccurrencesOfString:@"{" withString:@"("];&lt;br /&gt;    testString = [testString stringByReplacingOccurrencesOfString:@"}" withString:@")"];&lt;br /&gt;    &lt;br /&gt;    // push it&lt;br /&gt;    system([PUSH_CMD UTF8String]);    &lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  [NSThread sleepForTimeInterval:(double) delay];&lt;br /&gt;  if (SHOW_TICK) printf("tick\n");&lt;br /&gt; }&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;There is also a Mac Xcode project sample on how to push from Desktop App here&lt;br /&gt;&lt;a href="http://stefan.hafeneger.name/download/PushMeBabySource.zip"&gt;http://stefan.hafeneger.name/download/PushMeBabySource.zip&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-1504842176404267712?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/1504842176404267712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=1504842176404267712' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1504842176404267712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1504842176404267712'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/04/apns-pushing-tweets-to-iphone.html' title='APNS : Pushing tweets to iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-4973694097846914649</id><published>2009-04-13T14:55:00.014+08:00</published><updated>2009-04-15T09:49:57.286+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Push Notification Service'/><title type='text'>APNS : How to generate JSON payload in C</title><content type='html'>For the communication program with APNS, you have many implementation choices, either php, perl, python, ruby or even C#.  &lt;br /&gt;&lt;br /&gt;You may wonder why the sample of raw interface given by Apple is a C function.&lt;br /&gt;&lt;code&gt;static bool sendPayload(SSL *sslPtr, char *deviceTokenBinary, char *payloadBuff, size_t payloadLength)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Would there be many implementations that use C /C++ or Objective C ?  I guess the number will be increasing if the developer is looking for scalability and performance.&lt;br /&gt;&lt;br /&gt;If you would like to implement it in C variant, you need to implement a raw TLS/SSL socket program (and may be with threading) and the handling of JSON payload.  One of the possibilities is to use open source JSON C Library, but I think it is too heavy to use it here as the communication program needs to construct the Payload message only.  So I write this function (genPayloadData ) to generate the payload message for the APNS.&lt;br /&gt;&lt;br /&gt;This source code includes the JSON escape string function and the C structure to generate the APNS Payload.&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; apns.c &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;strings.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#define Debug 1&lt;br /&gt;#define logerror dprintf&lt;br /&gt;#define dprintf if (Debug) printf&lt;br /&gt;&lt;br /&gt;#define DEVICE_BINARY_SIZE 32&lt;br /&gt;#define MAXPAYLOAD_SIZE 256&lt;br /&gt;&lt;br /&gt;typedef struct&lt;br /&gt;{&lt;br /&gt; char* alert;&lt;br /&gt; int badge;&lt;br /&gt; char* sound;&lt;br /&gt; char* name_key[4];  //custom key&lt;br /&gt; char* str_value[4];   // custom key value&lt;br /&gt; int int_value[4];       // custom key int&lt;br /&gt; char* action_loc_key;  // for custom button label&lt;br /&gt; char* loc_key;          // formatted localized string&lt;br /&gt; char* loc_args[4];   // formatted localized string arguments&lt;br /&gt;} PayloadData;&lt;br /&gt;&lt;br /&gt;/* string escaping */&lt;br /&gt;const char *json_number_chars = "0123456789.+-eE";&lt;br /&gt;const char *json_hex_chars = "0123456789abcdef";&lt;br /&gt;&lt;br /&gt;char *json_escape_str(char *str)&lt;br /&gt;{&lt;br /&gt; char *results = (char*)malloc(200);&lt;br /&gt; char *resultsPt = results;&lt;br /&gt; int pos = 0, start_offset = 0;&lt;br /&gt; unsigned char c;&lt;br /&gt; do {&lt;br /&gt;  c = str[pos];&lt;br /&gt;  switch(c) {&lt;br /&gt;   case '\0':&lt;br /&gt;    break;&lt;br /&gt;   case '\b':&lt;br /&gt;   case '\n':&lt;br /&gt;   case '\r':&lt;br /&gt;   case '\t':&lt;br /&gt;   case '"':&lt;br /&gt;   case '\\':&lt;br /&gt;   case '/':&lt;br /&gt;    if(pos - start_offset &gt; 0)&lt;br /&gt;     {memcpy(resultsPt, str + start_offset, pos - start_offset); resultsPt+=pos - start_offset;} &lt;br /&gt;    if(c == '\b')  {memcpy(resultsPt, "\\b", 2); resultsPt+=2;} &lt;br /&gt;    else if(c == '\n') {memcpy(resultsPt, "\\n", 2); resultsPt+=2;} &lt;br /&gt;    else if(c == '\r') {memcpy(resultsPt, "\\r", 2); resultsPt+=2;} &lt;br /&gt;    else if(c == '\t') {memcpy(resultsPt, "\\t", 2); resultsPt+=2;} &lt;br /&gt;    else if(c == '"') {memcpy(resultsPt, "\\\"", 2); resultsPt+=2;} &lt;br /&gt;    else if(c == '\\') {memcpy(resultsPt, "\\\\", 2); resultsPt+=2;} &lt;br /&gt;    else if(c == '/') {memcpy(resultsPt, "\\/", 2); resultsPt+=2;} &lt;br /&gt;    start_offset = ++pos;&lt;br /&gt;    break;&lt;br /&gt;   default:&lt;br /&gt;    if(c &lt; ' ') {&lt;br /&gt;     if(pos - start_offset &gt; 0)&lt;br /&gt;      {memcpy(resultsPt, str + start_offset, pos - start_offset); resultsPt+=pos-start_offset;} &lt;br /&gt;     sprintf(resultsPt, "\\u00%c%c",&lt;br /&gt;         json_hex_chars[c &gt;&gt; 4],&lt;br /&gt;         json_hex_chars[c &amp; 0xf]);&lt;br /&gt;     start_offset = ++pos;&lt;br /&gt;    } else pos++;&lt;br /&gt;  }&lt;br /&gt; } while(c);&lt;br /&gt; if(pos - start_offset &gt; 0)&lt;br /&gt;  {memcpy(resultsPt, str + start_offset, pos - start_offset); resultsPt+=pos-start_offset;} &lt;br /&gt; memcpy(resultsPt, "\0", 1);&lt;br /&gt; dprintf("results:%s\n",results);&lt;br /&gt; return results;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#define APSHEAD "{\"aps\":{"&lt;br /&gt;#define APSTAIL "}"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void genPayloadData(PayloadData myPaylodData, char *msgbuf) {&lt;br /&gt; char *alert = (char*)malloc(200);&lt;br /&gt; char *message = (char*)malloc(200);&lt;br /&gt; char *sound = (char*)malloc(20);&lt;br /&gt; char *badge = (char *)malloc(20);&lt;br /&gt; char *msgbufPt = msgbuf;&lt;br /&gt; bool isAlert=false, isBadge=false, isSound=false;&lt;br /&gt; bool isToken=false;&lt;br /&gt; int len;&lt;br /&gt; int i;&lt;br /&gt;&lt;br /&gt; if (myPaylodData.alert) {&lt;br /&gt;  if (myPaylodData.action_loc_key) {&lt;br /&gt;   sprintf(alert, "\"alert\":{\"body\":\"%s\",\"action-loc-key\":\"%s\"}",json_escape_str(myPaylodData.alert),json_escape_str(myPaylodData.action_loc_key));&lt;br /&gt;  }&lt;br /&gt;  else {&lt;br /&gt;   sprintf(alert, "\"alert\":\"%s\"",json_escape_str(myPaylodData.alert));&lt;br /&gt;  }&lt;br /&gt;  isAlert = true;&lt;br /&gt; } else if (myPaylodData.loc_key) {  &lt;br /&gt;  isToken=false;&lt;br /&gt;  sprintf(alert, "\"alert\":{\"loc-key\":\"%s\"",json_escape_str(myPaylodData.loc_key));&lt;br /&gt;  for (i=0 ; i &lt; 4; i++) {&lt;br /&gt;   if (myPaylodData.loc_args[i]) {&lt;br /&gt;    if (isToken) {&lt;br /&gt;     sprintf(alert, "%s,\"%s\"",alert,json_escape_str(myPaylodData.loc_args[i]));&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;     sprintf(alert, "%s,\"loc-args\":[\"%s\"",alert,json_escape_str(myPaylodData.loc_args[i]));&lt;br /&gt;    }&lt;br /&gt;    isToken=true;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  if (isToken) {&lt;br /&gt;   sprintf(alert, "%s]}",alert);&lt;br /&gt;  }&lt;br /&gt;  isAlert = true;&lt;br /&gt; }&lt;br /&gt; if (myPaylodData.badge &gt; 0) {&lt;br /&gt;  sprintf(badge, "\"badge\":%d",myPaylodData.badge);&lt;br /&gt;  isBadge = true;&lt;br /&gt; }&lt;br /&gt; if (myPaylodData.sound) {&lt;br /&gt;  sprintf(sound, "\"sound\":\"%s\"",myPaylodData.sound);&lt;br /&gt;  isSound = true;&lt;br /&gt; }&lt;br /&gt; if (isAlert | isBadge | isSound) {&lt;br /&gt;  len =  strlen(APSHEAD);&lt;br /&gt;  memcpy(msgbufPt, APSHEAD, len);&lt;br /&gt;  msgbufPt += len;&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  memcpy(msgbufPt, "{", 1);&lt;br /&gt;  msgbufPt += 1;&lt;br /&gt; }&lt;br /&gt; if (isAlert) {&lt;br /&gt;  len =  strlen(alert);&lt;br /&gt;  memcpy(msgbufPt, alert, len);&lt;br /&gt;  msgbufPt += len;&lt;br /&gt; }&lt;br /&gt; if (isBadge) {&lt;br /&gt;  if (isAlert) {&lt;br /&gt;   memcpy(msgbufPt++, ",", 1);&lt;br /&gt;  }&lt;br /&gt;  len =  strlen(badge);&lt;br /&gt;  memcpy(msgbufPt, badge, len);&lt;br /&gt;  msgbufPt += len;&lt;br /&gt; }&lt;br /&gt; if (isSound) {&lt;br /&gt;  if (isAlert | isBadge) {&lt;br /&gt;   memcpy(msgbufPt++, ",", 1);&lt;br /&gt;  }&lt;br /&gt;  len =  strlen(sound);&lt;br /&gt;  memcpy(msgbufPt, sound, len);&lt;br /&gt;  msgbufPt += len;&lt;br /&gt; }&lt;br /&gt; if (isAlert | isBadge | isSound) {&lt;br /&gt;  len =  strlen(APSTAIL);&lt;br /&gt;  memcpy(msgbufPt, APSTAIL, len);&lt;br /&gt;  msgbufPt += len;&lt;br /&gt;  isToken = true;&lt;br /&gt; }&lt;br /&gt; isToken=false;&lt;br /&gt; if (msgbufPt-msgbuf &amp;lt; MAXPAYLOAD_SIZE) {&lt;br /&gt;  for (i=0; i &lt; 4; i++) {&lt;br /&gt;   if (myPaylodData.name_key[i]) {&lt;br /&gt;    if (myPaylodData.str_value[i]) {&lt;br /&gt;     sprintf(message, "%s\"%s\":\"%s\"",(isToken?",":""),json_escape_str(myPaylodData.name_key[i]),json_escape_str(myPaylodData.str_value[i]));&lt;br /&gt;     len =  strlen(message);&lt;br /&gt;     if (msgbufPt-msgbuf+len&amp;lt;MAXPAYLOAD_SIZE) {&lt;br /&gt;      memcpy(msgbufPt, message, len);&lt;br /&gt;      msgbufPt += len;&lt;br /&gt;      isToken = true;&lt;br /&gt;     }&lt;br /&gt;     else {&lt;br /&gt;      dprintf("\n!!!!Warnings: Total Payload message overlimit (&amp;gt;%d) when processing %s",MAXPAYLOAD_SIZE,message);&lt;br /&gt;     }     &lt;br /&gt;    }&lt;br /&gt;    if (myPaylodData.int_value[i]) {&lt;br /&gt;     sprintf(message, "%s\"%s\":%d",(isToken?",":""),json_escape_str(myPaylodData.name_key[i]),myPaylodData.int_value[i]);&lt;br /&gt;     len =  strlen(message);&lt;br /&gt;     if (msgbufPt-msgbuf+len&amp;lt;MAXPAYLOAD_SIZE) {&lt;br /&gt;      memcpy(msgbufPt, message, len);&lt;br /&gt;      msgbufPt += len;&lt;br /&gt;      isToken = true;&lt;br /&gt;     }&lt;br /&gt;     else {&lt;br /&gt;      dprintf("\n!!!!Warnings: Total Payload message overlimit (&amp;gt;%d) when processing %s",MAXPAYLOAD_SIZE,message);&lt;br /&gt;     }     &lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; len =  strlen(APSTAIL);&lt;br /&gt; memcpy(msgbufPt, APSTAIL, len);&lt;br /&gt; msgbufPt += len;&lt;br /&gt;  memcpy(msgbufPt, "\0", 1);&lt;br /&gt; dprintf("\nconstructed message:%s\n",msgbuf);&lt;br /&gt; if (strlen(msgbuf) &gt; MAXPAYLOAD_SIZE) {&lt;br /&gt;  dprintf("\n!!!!Warnings: Payload (&amp;gt;%d) : %d\n",MAXPAYLOAD_SIZE,(unsigned)strlen(msgbuf));&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  dprintf("\nPayload (&amp;lt;=%d) size : %d\n",MAXPAYLOAD_SIZE,(unsigned)strlen(msgbuf));&lt;br /&gt; }&lt;br /&gt; free(alert);&lt;br /&gt; free(badge);&lt;br /&gt; free(sound);&lt;br /&gt; free(message);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(){&lt;br /&gt;         char msgbuf[512];   /* payload messages */&lt;br /&gt;&lt;br /&gt;  PayloadData myPaylodData = {0};&lt;br /&gt;  myPaylodData.badge = 3;&lt;br /&gt;  myPaylodData.alert = "Message from javacom";&lt;br /&gt;//  myPaylodData.action_loc_key = "";&lt;br /&gt;//  myPaylodData.loc_args[0] = "";&lt;br /&gt;//  myPaylodData.loc_args[1] = "";&lt;br /&gt;//  myPaylodData.loc_args[2] = "";&lt;br /&gt;  myPaylodData.sound = "received3.caf";&lt;br /&gt;  myPaylodData.name_key[0] = "test1";&lt;br /&gt;  myPaylodData.str_value[0] = "Hello iPhone";&lt;br /&gt;  genPayloadData(myPaylodData,msgbuf);&lt;br /&gt;  printf("%s\n",msgbuf);&lt;br /&gt;  return 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-4973694097846914649?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/4973694097846914649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=4973694097846914649' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/4973694097846914649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/4973694097846914649'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/04/apns-how-to-generate-json-payload-in-c.html' title='APNS : How to generate JSON payload in C'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-6624700113588907307</id><published>2009-04-10T08:01:00.084+08:00</published><updated>2011-07-25T06:53:04.252+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Push Notification Service'/><title type='text'>APNS Client Development Certificate Available Now</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sd6MsysT5JI/AAAAAAAAAtM/lP4GuZJ_tdM/s1600-h/apnsrequest.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 364px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sd6MsysT5JI/AAAAAAAAAtM/lP4GuZJ_tdM/s400/apnsrequest.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5322846510748263570" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(1) You need to create an App ID without &lt;span style="font-weight:bold;"&gt;.*&lt;/span&gt;  in the Program Portal (that means one cert for one app)&lt;br /&gt;&lt;br /&gt;(2) Generate a certificate signing request from your Mac's keychain and &lt;span style="font-weight:bold;"&gt;save to disk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(3) Upload the CertificateSigningRequest.certSigningRequest to the Program Portal&lt;br /&gt;&lt;br /&gt;(4) Wait for the generation of cert (about 1 min).  Download the certificate (aps_developer_identity.cer) from the Program Portal &lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;  (If you need to renew this cert, it is under the App ID that you created in step 1, and choose Action Configure)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(5) Keep (or rename them if you prefer) these 2 files (steps 2 and 4) in a safe place.  You might need the CertificateSigningRequest.certSigningRequest file to request a new cert for a new app in the future or renew the old cert when expired.&lt;br /&gt;&lt;br /&gt;(6) Suppose you have imported the aps_developer_identity.cer to the keychain.  Then you have to export these new cert and the &lt;span style="font-weight:bold;"&gt;private key&lt;/span&gt; of this cert (not the public key) and saved as .p12 files.&lt;br /&gt;&lt;br /&gt;(7) Then you use these commands to generate the cert and key in Mac's Terminal for PEM format (Privacy Enhanced Mail Security Certificate)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  openssl pkcs12 -clcerts -nokeys -out cert.pem -in cert.p12&lt;br /&gt;  openssl pkcs12 -nocerts -out key.pem -in key.p12&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(8) The cert.pem and key.pem files will be used by your own php script communicating with APNS.&lt;br /&gt;&lt;br /&gt;(9) If you want to remove the passphase of private key in key.pem, do this&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  openssl rsa -in key.pem -out key.unencrypted.pem&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then combine the certificate and key&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  cat cert.pem key.unencrypted.pem &amp;gt; ck.pem&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;But please set the file permission of this unencrypted key by using &lt;span style="font-style:italic;"&gt;chmod 400&lt;/span&gt; and is only readable by root in a sever configuration.&lt;br /&gt;&lt;br /&gt;(10) The testing APNS is at ssl://gateway.sandbox.push.apple.com:2195&lt;br /&gt;&lt;br /&gt;(11) For the source codes to push payload message to the APNS, you can find them in the Developer Forum.  This is the one that I used, for php script.  Run this (after obtaining the device token from the testing device and with iPhone Client program setup)&lt;br /&gt;&lt;code&gt;php -f apns.php "My Message" 2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;or if you put this php script and the ck.pem in a local web server, you can use this to test&lt;br /&gt;&lt;code&gt;http://127.0.0.1/apns/apns.php?message=test%20from%20javacom&amp;amp;badge=2&amp;amp;sound=received5.caf&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Please be patient to get message from the sandbox server.  Normally, you need 10 minutes+ to get the first message from push notification testing.&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; apns.php &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env php&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$deviceToken = '02da851dXXXXXXXXb4f2b5bfXXXXXXXXce198270XXXXXXXX0d3dac72bc87cd60';  // masked for security reason&lt;br /&gt;// Passphrase for the private key (ck.pem file)&lt;br /&gt;// $pass = '';&lt;br /&gt;&lt;br /&gt;// Get the parameters from http get or from command line&lt;br /&gt;$message = $_GET['message'] or $message = $argv[1] or $message = 'Message received from javacom';&lt;br /&gt;$badge = (int)$_GET['badge'] or $badge = (int)$argv[2];&lt;br /&gt;$sound = $_GET['sound'] or $sound = $argv[3];&lt;br /&gt;&lt;br /&gt;// Construct the notification payload&lt;br /&gt;$body = array();&lt;br /&gt;$body['aps'] = array('alert' =&gt; $message);&lt;br /&gt;if ($badge)&lt;br /&gt;$body['aps']['badge'] = $badge;&lt;br /&gt;if ($sound)&lt;br /&gt;$body['aps']['sound'] = $sound;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/* End of Configurable Items */&lt;br /&gt;&lt;br /&gt;$ctx = stream_context_create();&lt;br /&gt;stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');&lt;br /&gt;// assume the private key passphase was removed.&lt;br /&gt;// stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);&lt;br /&gt;&lt;br /&gt;$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);&lt;br /&gt;// for production change the server to ssl://gateway.push.apple.com:2195&lt;br /&gt;if (!$fp) {&lt;br /&gt; print "Failed to connect $err $errstr\n";&lt;br /&gt; return;&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;print "Connection OK\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$payload = json_encode($body);&lt;br /&gt;$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;&lt;br /&gt;print "sending message :" . $payload . "\n";&lt;br /&gt;fwrite($fp, $msg);&lt;br /&gt;fclose($fp);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;code&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(12) For iPhone Client Program, you need to edit the bundle identifier to the App ID that you created and imported the new provisioning profile for that APP ID to the XCode and iPhone.  &lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;And codesign with that new provisioning profile&lt;/span&gt;. Then implement the following methods in AppDelegate to Build &amp;amp; Go&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; AppDelegate.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;- (void)applicationDidFinishLaunching:(UIApplication *)application { &lt;br /&gt;  NSLog(@"Registering Remote Notications");&lt;br /&gt;&lt;br /&gt;   [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];&lt;br /&gt;&lt;br /&gt; // Override point for customization after app launch &lt;br /&gt; [window addSubview:viewController.view];&lt;br /&gt; [window makeKeyAndVisible];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Delegation methods&lt;br /&gt;- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {&lt;br /&gt;  const void *devTokenBytes = [devToken bytes];&lt;br /&gt;//    self.registered = YES;&lt;br /&gt;  NSLog(@"deviceToken: %@", devToken);&lt;br /&gt;//    [self sendProviderDeviceToken:devTokenBytes]; // custom method&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {&lt;br /&gt;  NSLog(@"Error in registration. Error: %@", err);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;code&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(13) Additional tips for sandbox testing&lt;br /&gt;- The feedback service is feedback.sandbox.push.apple.com:2195&lt;br /&gt;- Send your messages to gateway.sandbox.push.apple.com:2195&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/52282-apns2-embed.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;Here is the feedback server request php code.  For the sandbox feedback server, you have to create a second dummy app to make the first one works.  May be the sandbox feedback server is buggy as the production push and feedback servers does not have this problem.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;php -f feedback.php&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; feedback.php &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env php&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$ctx = stream_context_create();&lt;br /&gt;stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');&lt;br /&gt;stream_context_set_option($ctx, 'ssl', 'verify_peer', false);&lt;br /&gt;// assume the private key passphase was removed.&lt;br /&gt;// stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$fp = stream_socket_client('ssl://feedback.sandbox.push.apple.com:2196', $error, $errorString, 60, STREAM_CLIENT_CONNECT, $ctx);&lt;br /&gt;// production server is ssl://feedback.push.apple.com:2196&lt;br /&gt;&lt;br /&gt;if (!$fp) {&lt;br /&gt;    print "Failed to connect feedback server: $err $errstr\n";&lt;br /&gt;    return;&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;   print "Connection to feedback server OK\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;        print "APNS feedback results\n";&lt;br /&gt;        while ($devcon = fread($fp, 38))&lt;br /&gt;        {&lt;br /&gt;   $arr = unpack("H*", $devcon); &lt;br /&gt;   $rawhex = trim(implode("", $arr));&lt;br /&gt;   $feedbackTime = hexdec(substr($rawhex, 0, 8)); &lt;br /&gt;   $feedbackDate = date('Y-m-d H:i', $feedbackTime); &lt;br /&gt;   $feedbackLen = hexdec(substr($rawhex, 8, 4)); &lt;br /&gt;   $feedbackDeviceToken = substr($rawhex, 12, 64);&lt;br /&gt;   print "TIMESTAMP:" . $feedbackDate . "\n";&lt;br /&gt;          print "DEVICE ID:" . $feedbackDeviceToken. "\n\n";&lt;br /&gt;        }&lt;br /&gt;fclose($fp);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;code&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hints: If you want to test the production push and feedback servers, use the adhoc distribution certificate and adhoc build to your devices.  Moreover, the device tokens are different for the same device under sandbox and production servers.&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-6624700113588907307?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/6624700113588907307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=6624700113588907307' title='42 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6624700113588907307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6624700113588907307'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/04/apns-client-development-certificate.html' title='APNS Client Development Certificate Available Now'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/Sd6MsysT5JI/AAAAAAAAAtM/lP4GuZJ_tdM/s72-c/apnsrequest.png' height='72' width='72'/><thr:total>42</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7572458111799403794</id><published>2009-04-06T17:46:00.021+08:00</published><updated>2009-04-08T09:29:01.439+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='UIAccelerometer'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenGL ES'/><title type='text'>OpenGL ES for iPhone : Part 3 with Accelerometer control</title><content type='html'>In this part 3, we will add the accelerometer control to move the position of ellipse object that we have created in part 2 of the Tutorial.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SdnfbfBtByI/AAAAAAAAAs0/PNP1IV0AbdY/s1600-h/opengl_p3a.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 267px; height: 400px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SdnfbfBtByI/AAAAAAAAAs0/PNP1IV0AbdY/s400/opengl_p3a.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321530097993058082" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1) UIAccelerometerDelegate&lt;/span&gt;&lt;br /&gt;We need to add the &lt;span style="font-weight:bold;"&gt;UIAccelerometerDelegate&lt;/span&gt; protocol to the EAGLView and implement the &lt;span style="font-weight:bold;"&gt;accelerometer: didAccelerate:&lt;/span&gt; method as below&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@interface EAGLView : UIView &lt;span style="font-weight:bold;"&gt;&amp;lt;UIAccelerometerDelegate&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- (void)&lt;span style="font-weight:bold;"&gt;accelerometer:&lt;/span&gt;(UIAccelerometer*)accelerometer &lt;span style="font-weight:bold;"&gt;didAccelerate:&lt;/span&gt;(UIAcceleration*)acceleration&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;We need to configure and start the accelerometer in the &lt;span style="font-weight:bold;"&gt;setupView&lt;/span&gt; method&lt;br /&gt;&lt;code&gt;&lt;br /&gt; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)];&lt;br /&gt; [[UIAccelerometer sharedAccelerometer] setDelegate:self];&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2) Accelerometer values&lt;/span&gt;&lt;br /&gt;Inside the &lt;span style="font-weight:bold;"&gt;accelerometer: didAccelerate:&lt;/span&gt; method, we add a low-pass filter in the accelerometer values.  This low-pass filter codes are sourced from the GLGravity Sample Code from Apple.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//Use a basic low-pass filter in the accelerometer values&lt;br /&gt; accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);&lt;br /&gt; accel[1] = acceleration.y * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);&lt;br /&gt; accel[2] = acceleration.z * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The meaning of accelerometer values:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;acceleration.x &lt;/span&gt;= Roll. It corresponds to roll, or rotation around the axis that runs from your home button to your earpiece.  Values vary from 1.0 (rolled all the way to the right) to -1.0 (rolled all the way to the left).&lt;br /&gt;  &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;acceleration.y&lt;/span&gt; = Pitch. Place your iPhone on the table and mentally draw a horizontal line about half-way down the screen.  That's the axis around which the Y value rotates.  Values go from 1.0 (the headphone jack straight down) to -1.0 (the headphone jack straight up).&lt;br /&gt;  &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;acceleration.z&lt;/span&gt; = Face up/face down.  It refers to whether your iPhone is face up (-1.0) or face down (1.0).   When placed on it side, either the side with the volume controls and ringer switch, or the side directly opposite, the Z value equates to 0.0.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;3) Control on movement of the ellipse&lt;/span&gt; is using the variables moveX and moveY and the ellipse position will be changed according to acceleration.x (that is accel[0]) and acceleration.y (that is accel[1]) values that passed from the Accelerometer control after the low-pass filter.  The larger the absolute value of acceleration.x/acceleration.y, the greater for the magnitude for the value of moveX/moveY and thus the faster the ellipse will change its position to that direction.  As the object should not move beyond the screen view, the ellipseData.pos.x and ellipseData.pos.y values will be governed by the boundaries of the screen.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;ellipseData.pos.x += moveX;&lt;br /&gt;&amp;nbsp;if (accel[0] &gt; -0.1 &amp; accel[0] &lt; 0.1 ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;moveX = 0.0f;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;moveX = 10.0f * accel[0];&lt;br /&gt;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;ellipseData.pos.y += moveY;&lt;br /&gt;&amp;nbsp;if (accel[1] &gt; -0.1 &amp; accel[1] &lt; 0.1 ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;moveY = 0.0f;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;moveY = -10.0f * accel[1];&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;4) Conditional compilation code for the iPhone Simulator and on-screen debug info&lt;/span&gt;&lt;br /&gt;As iPhone Simulator does not have Accelerometer control, we have added the code that will change the ellipse position inside this compiler directive, so that the ellipse will keep moving on the iPhone Simulator.&lt;br /&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;#if TARGET_IPHONE_SIMULATOR&lt;/code&gt; &lt;br /&gt;&lt;br /&gt;Moroever, we have added a UILabel to the code so that we can read the Accelerometer values while we debug the program on actual device.  This UILabel can be disabled using this define directive.&lt;br /&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;#undef DEBUGSCREEN&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;5) The source codes are here&lt;/span&gt;, you just need to create a new project from &lt;span style="font-style:italic;"&gt;OpenGL ES Application&lt;/span&gt; template of XCode and copy the source codes of EAGLView.h and EAGLView.m from below and paste them for Build &amp; Go in XCode.  The accelerometer control can only be tested on actual device.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SdghqFAVDCI/AAAAAAAAAsM/GMTiRaDo44c/s1600-h/opengles_template.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 113px; height: 113px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SdghqFAVDCI/AAAAAAAAAsM/GMTiRaDo44c/s400/opengles_template.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321039966520020002" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.h &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  EAGLView.h&lt;br /&gt;//  OpenGL ES Tutorial - Part 3 by javacom&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// To enable Debug NSLog, add GCC_PREPROCESSOR_DEFINITIONS DEBUGON in Project Settings for Debug Build Only and replace NSLog() with DEBUGLOG()&lt;br /&gt;#ifdef DEBUGON&lt;br /&gt;#define DEBUGLOG if (DEBUGON) NSLog&lt;br /&gt;#else&lt;br /&gt;#define DEBUGLOG&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#define DEBUGSCREEN &lt;br /&gt;&lt;br /&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGL.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/ES1/gl.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/ES1/glext.h&amp;gt;&lt;br /&gt;&lt;br /&gt;typedef struct&lt;br /&gt; {&lt;br /&gt;  BOOL rotstop;                   // stop self rotation&lt;br /&gt;  BOOL touchInside;               // finger tap inside of the object ? &lt;br /&gt;  BOOL scalestart;                // start to scale the obejct ?&lt;br /&gt;  CGPoint pos;                    // position of the object on the screen&lt;br /&gt;  CGPoint startTouchPosition;     // Start Touch Position&lt;br /&gt;  CGPoint currentTouchPosition;   // Current Touch Position&lt;br /&gt;  GLfloat pinchDistance;          // distance between two fingers pinch&lt;br /&gt;  GLfloat pinchDistanceShown;     // distance that have shown on screen&lt;br /&gt;  GLfloat scale;                  // OpenGL scale factor of the object&lt;br /&gt;  GLfloat rotation;               // OpenGL rotation factor of the object&lt;br /&gt;  GLfloat rotspeed;               // control rotation speed of the object&lt;br /&gt; } ObjectData;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt; This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.&lt;br /&gt; The view content is basically an EAGL surface you render your OpenGL scene into.&lt;br /&gt; Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.&lt;br /&gt; */&lt;br /&gt;@interface EAGLView : UIView &lt;UIAccelerometerDelegate&gt;{&lt;br /&gt;    &lt;br /&gt;@private&lt;br /&gt;    /* The pixel dimensions of the backbuffer */&lt;br /&gt;    GLint backingWidth;&lt;br /&gt;    GLint backingHeight;&lt;br /&gt;    &lt;br /&gt;    EAGLContext *context;&lt;br /&gt;    &lt;br /&gt;    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */&lt;br /&gt;    GLuint viewRenderbuffer, viewFramebuffer;&lt;br /&gt;    &lt;br /&gt;    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */&lt;br /&gt;    GLuint depthRenderbuffer;&lt;br /&gt;    &lt;br /&gt;    NSTimer *animationTimer;&lt;br /&gt;    NSTimeInterval animationInterval;&lt;br /&gt; &lt;br /&gt;@public&lt;br /&gt; ObjectData squareData;&lt;br /&gt; ObjectData ellipseData;&lt;br /&gt; GLfloat ellipseVertices[720];&lt;br /&gt; CGFloat initialDistance;&lt;br /&gt; UIAccelerationValue  accel[3];&lt;br /&gt; GLfloat moveX, moveY;&lt;br /&gt;#ifdef DEBUGSCREEN&lt;br /&gt; UILabel *textView;&lt;br /&gt;#endif&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property NSTimeInterval animationInterval;&lt;br /&gt;&lt;br /&gt;@property (nonatomic) ObjectData squareData;&lt;br /&gt;@property (nonatomic) ObjectData ellipseData;&lt;br /&gt;@property CGFloat initialDistance;&lt;br /&gt;#ifdef DEBUGSCREEN&lt;br /&gt;@property (nonatomic, assign) UILabel *textView;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;- (void)startAnimation;&lt;br /&gt;- (void)stopAnimation;&lt;br /&gt;- (void)drawView;&lt;br /&gt;- (void)setupView;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  EAGLView.m&lt;br /&gt;//  OpenGL ES Tutorial - Part 3 by javacom&lt;br /&gt;//&lt;br /&gt;#import &amp;lt;QuartzCore/QuartzCore.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGLDrawable.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#import "EAGLView.h"&lt;br /&gt;&lt;br /&gt;#include &amp;lt;math.h&amp;gt;&lt;br /&gt;&lt;br /&gt;// Macros&lt;br /&gt;#define degreesToRadians(__ANGLE__) (M_PI * (__ANGLE__) / 180.0)&lt;br /&gt;#define radiansToDegrees(__ANGLE__) (180.0 * (__ANGLE__) / M_PI)&lt;br /&gt;&lt;br /&gt;CGFloat distanceBetweenPoints (CGPoint first, CGPoint second) {&lt;br /&gt; CGFloat deltaX = second.x - first.x;&lt;br /&gt; CGFloat deltaY = second.y - first.y;&lt;br /&gt; return sqrt(deltaX*deltaX + deltaY*deltaY );&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;CGFloat angleBetweenPoints(CGPoint first, CGPoint second) {&lt;br /&gt; // atan((top - bottom)/(right - left))&lt;br /&gt; CGFloat rads = atan((second.y - first.y) / (first.x - second.x));&lt;br /&gt; return radiansToDegrees(rads);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint line2End) {&lt;br /&gt; &lt;br /&gt; CGFloat a = line1End.x - line1Start.x;&lt;br /&gt; CGFloat b = line1End.y - line1Start.y;&lt;br /&gt; CGFloat c = line2End.x - line2Start.x;&lt;br /&gt; CGFloat d = line2End.y - line2Start.y;&lt;br /&gt; &lt;br /&gt; CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));&lt;br /&gt; &lt;br /&gt; return radiansToDegrees(rads);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#define USE_DEPTH_BUFFER 0&lt;br /&gt;&lt;br /&gt;// CONSTANTS&lt;br /&gt;#define kMinimumTouchLength 30&lt;br /&gt;#define kMaximumScale 7.0f&lt;br /&gt;#define kMinimumPinchDelta 15&lt;br /&gt;#define kAccelerometerFrequency  100.0 // Hz&lt;br /&gt;#define kFilteringFactor   0.1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// A class extension to declare private methods&lt;br /&gt;@interface EAGLView ()&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) EAGLContext *context;&lt;br /&gt;@property (nonatomic, assign) NSTimer *animationTimer;&lt;br /&gt;&lt;br /&gt;- (BOOL) createFramebuffer;&lt;br /&gt;- (void) destroyFramebuffer;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@implementation EAGLView&lt;br /&gt;&lt;br /&gt;@synthesize context;&lt;br /&gt;@synthesize animationTimer;&lt;br /&gt;@synthesize animationInterval;&lt;br /&gt;@synthesize squareData;&lt;br /&gt;@synthesize ellipseData;&lt;br /&gt;@synthesize initialDistance;&lt;br /&gt;#ifdef DEBUGSCREEN&lt;br /&gt;@synthesize textView;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;// You must implement this method&lt;br /&gt;+ (Class)layerClass {&lt;br /&gt;    return [CAEAGLLayer class];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:&lt;br /&gt;- (id)initWithCoder:(NSCoder*)coder {&lt;br /&gt;    &lt;br /&gt;    if ((self = [super initWithCoder:coder])) {&lt;br /&gt;  &lt;br /&gt;        // Get the layer&lt;br /&gt;        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;&lt;br /&gt;        &lt;br /&gt;        eaglLayer.opaque = YES;&lt;br /&gt;        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:&lt;br /&gt;                                        [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];&lt;br /&gt;        &lt;br /&gt;        context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];&lt;br /&gt;        &lt;br /&gt;        if (!context || ![EAGLContext setCurrentContext:context]) {&lt;br /&gt;            [self release];&lt;br /&gt;            return nil;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        animationInterval = 1.0 / 60.0;&lt;br /&gt;  [self setupView];&lt;br /&gt;    }&lt;br /&gt;    return self;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// These are four methods touchesBegan, touchesMoved, touchesEnded, touchesCancelled and use to notify about touches and gestures&lt;br /&gt;&lt;br /&gt;- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; /*&lt;br /&gt;  NSUInteger numTaps = [[touches anyObject] tapCount];  // number of taps&lt;br /&gt;  NSUInteger numTouches = [touches count];              // number of touches&lt;br /&gt;  */ &lt;br /&gt; UITouch *touch = [[touches allObjects] objectAtIndex:0];&lt;br /&gt; &lt;br /&gt; DEBUGLOG(@"TouchBegan event counts = %d ",[[event touchesForView:self] count]);&lt;br /&gt; DEBUGLOG(@"TouchBegan tounches counts = %d ",[touches count]);&lt;br /&gt; if ([touches count]== 2) {&lt;br /&gt;  NSArray *twoTouches = [touches allObjects];&lt;br /&gt;  UITouch *first = [twoTouches objectAtIndex:0];&lt;br /&gt;  UITouch *second = [twoTouches objectAtIndex:1];&lt;br /&gt;  initialDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);  &lt;br /&gt;  squareData.rotstop = YES;&lt;br /&gt;  squareData.touchInside = NO;&lt;br /&gt; }&lt;br /&gt; else if ([touches count]==[[event touchesForView:self] count] &amp; [[event touchesForView:self] count] == 1) {&lt;br /&gt;  squareData.startTouchPosition = [touch locationInView:self];&lt;br /&gt;  if (distanceBetweenPoints([touch locationInView:self], squareData.pos) &lt;= kMinimumTouchLength * squareData.scale) {&lt;br /&gt;   DEBUGLOG(@"Square Touch at %.2f, %.2f ",squareData.pos.x,squareData.pos.y);&lt;br /&gt;   squareData.rotstop = YES;&lt;br /&gt;   squareData.touchInside = YES;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; UITouch *touch = [[touches allObjects] objectAtIndex:0];&lt;br /&gt; squareData.currentTouchPosition = [touch locationInView:self];&lt;br /&gt; if ([touches count]== 2) {&lt;br /&gt;  NSArray *twoTouches = [touches allObjects];&lt;br /&gt;  UITouch *first = [twoTouches objectAtIndex:0];&lt;br /&gt;  UITouch *second = [twoTouches objectAtIndex:1];&lt;br /&gt;  &lt;br /&gt;  // Calculate the distance bewtween the two fingers(touches) to determine the pinch distance&lt;br /&gt;  CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);&lt;br /&gt;  &lt;br /&gt;  squareData.rotstop = YES;&lt;br /&gt;  squareData.touchInside = NO;&lt;br /&gt;  &lt;br /&gt;  if (initialDistance == 0.0f)&lt;br /&gt;   initialDistance = currentDistance; &lt;br /&gt;  if (currentDistance - initialDistance &gt; kMinimumPinchDelta) {&lt;br /&gt;   squareData.pinchDistance = currentDistance - initialDistance;&lt;br /&gt;   squareData.scalestart = YES;&lt;br /&gt;   DEBUGLOG(@"Outward Pinch %.2f", squareData.pinchDistance);&lt;br /&gt;  }&lt;br /&gt;  else if (initialDistance - currentDistance &gt; kMinimumPinchDelta) {&lt;br /&gt;   squareData.pinchDistance = currentDistance - initialDistance;&lt;br /&gt;   squareData.scalestart = YES;&lt;br /&gt;   DEBUGLOG(@"Inward Pinch %.2f", squareData.pinchDistance);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; else if ([touches count]==[[event touchesForView:self] count] &amp; [[event touchesForView:self] count] == 1) {&lt;br /&gt;  if (squareData.touchInside) {&lt;br /&gt;   // Only move the square to new position when touchBegan is inside the square&lt;br /&gt;   squareData.pos.x = [touch locationInView:self].x;&lt;br /&gt;   squareData.pos.y = [touch locationInView:self].y;&lt;br /&gt;   DEBUGLOG(@"Square Move to %.2f, %.2f ",squareData.pos.x,squareData.pos.y);&lt;br /&gt;   squareData.rotstop = YES;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; if ([touches count] == [[event touchesForView:self] count]) {&lt;br /&gt;  initialDistance = squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;  squareData.rotstop = squareData.touchInside = squareData.scalestart = NO;&lt;br /&gt;  DEBUGLOG(@"touchesEnded, all fingers up");&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  initialDistance = squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;  squareData.scalestart = NO;&lt;br /&gt;  DEBUGLOG(@"touchesEnded");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; initialDistance = squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt; squareData.rotstop = squareData.touchInside = squareData.scalestart = NO;&lt;br /&gt; DEBUGLOG(@"touchesCancelled"); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)setupView {  // new method for intialisation of variables and states&lt;br /&gt; &lt;br /&gt; // Enable Multi Touch of the view&lt;br /&gt; self.multipleTouchEnabled = YES;&lt;br /&gt; &lt;br /&gt; //Configure and start accelerometer&lt;br /&gt; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)];&lt;br /&gt; [[UIAccelerometer sharedAccelerometer] setDelegate:self];&lt;br /&gt;#if TARGET_IPHONE_SIMULATOR&lt;br /&gt; moveX = 2.0f;&lt;br /&gt; moveY = 3.0f;&lt;br /&gt;#else&lt;br /&gt; moveX = 0.0f;&lt;br /&gt; moveY = 0.0f;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#ifdef DEBUGSCREEN&lt;br /&gt; UIColor *bgColor = [[UIColor alloc] initWithWhite:1.0f alpha:0.0f];&lt;br /&gt; textView = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 350.0f, 300.0f, 96.0f)];&lt;br /&gt; textView.text = [NSString stringWithFormat:@"-Accelerometer Data-"];&lt;br /&gt; textView.textAlignment = UITextAlignmentLeft;&lt;br /&gt; [textView setNumberOfLines:4];&lt;br /&gt; textView.backgroundColor = bgColor;&lt;br /&gt; textView.font = [UIFont fontWithName:@"Arial" size:18];&lt;br /&gt; [self addSubview:textView];&lt;br /&gt; [self bringSubviewToFront:textView];&lt;br /&gt;#endif &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; // Initialise square data&lt;br /&gt; squareData.rotation = squareData.pinchDistance = squareData.pinchDistanceShown = 0.0f;&lt;br /&gt; ellipseData.rotation = 0.0f;&lt;br /&gt; squareData.scale = 1.0f;&lt;br /&gt; squareData.rotstop = squareData.touchInside = squareData.scalestart = NO;&lt;br /&gt; squareData.pos.x = 160.0f;&lt;br /&gt; squareData.pos.y = 240.0f; &lt;br /&gt; squareData.pinchDistance = 0.0f;&lt;br /&gt; squareData.rotspeed = 1.0f;&lt;br /&gt; &lt;br /&gt; // Initialise ellipse data&lt;br /&gt; ellipseData.rotation = 0.0f;&lt;br /&gt; ellipseData.rotstop = ellipseData.touchInside = ellipseData.scalestart = NO;&lt;br /&gt; ellipseData.pos.x = 160.0f;&lt;br /&gt; ellipseData.pos.y = 100.0f; &lt;br /&gt; ellipseData.rotspeed = -4.0f;&lt;br /&gt; &lt;br /&gt; // calculate the vertices of ellipse&lt;br /&gt; const GLfloat xradius = 35.0f; &lt;br /&gt; const GLfloat yradius = 25.0f; &lt;br /&gt; for (int i = 0; i &lt; 720; i+=2) {&lt;br /&gt;  ellipseVertices[i] = (cos(degreesToRadians(i)) * xradius) + 0.0f;&lt;br /&gt;  ellipseVertices[i+1] = (sin(degreesToRadians(i)) * yradius) + 0.0f;&lt;br /&gt;//  DEBUGLOG(@"ellipseVertices[v%d] %.1f, %.1f",i, ellipseVertices[i], ellipseVertices[i+1]);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; // setup the projection matrix&lt;br /&gt; glMatrixMode(GL_PROJECTION);&lt;br /&gt; glLoadIdentity();&lt;br /&gt; &lt;br /&gt; // Setup Orthographic Projection for the 320 x 480 of the iPhone screen&lt;br /&gt; glOrthof(0.0f, 320.0f, 480.0f, 0.0f, -1.0f, 1.0f);&lt;br /&gt; glMatrixMode(GL_MODELVIEW);&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)drawView {&lt;br /&gt;    &lt;br /&gt;    // Define the square vertices&lt;br /&gt; const GLfloat squareVertices[] = {&lt;br /&gt;        -20.0f, -20.0f,&lt;br /&gt;        20.0f,  -20.0f,&lt;br /&gt;        -20.0f,  20.0f,&lt;br /&gt;        20.0f,   20.0f,&lt;br /&gt;    };&lt;br /&gt; &lt;br /&gt;    // Define the colors of the square vertices&lt;br /&gt; const GLubyte squareColors[] = {&lt;br /&gt;        255, 255,   0, 255,&lt;br /&gt;        0,   255, 255, 255,&lt;br /&gt;        0,     0,   0,   0,&lt;br /&gt;        255,   0, 255, 255,&lt;br /&gt;    };&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; // Define the colors of the ellipse vertices&lt;br /&gt; const GLubyte ellipseColors[] = {&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;    };&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    [EAGLContext setCurrentContext:context];&lt;br /&gt;    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);&lt;br /&gt;    glViewport(0, 0, backingWidth, backingHeight);&lt;br /&gt;    &lt;br /&gt; // Clear background color&lt;br /&gt;    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);&lt;br /&gt;    glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt; &lt;br /&gt; // draw the square&lt;br /&gt; glLoadIdentity();&lt;br /&gt; glTranslatef(squareData.pos.x, squareData.pos.y, 0.0f);&lt;br /&gt; glRotatef(squareData.rotation, 0.0f, 0.0f, 1.0f);&lt;br /&gt; glScalef(squareData.scale, squareData.scale, 1.0f);&lt;br /&gt; glVertexPointer(2, GL_FLOAT, 0, squareVertices);&lt;br /&gt; glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);&lt;br /&gt; glEnableClientState(GL_VERTEX_ARRAY);&lt;br /&gt; glEnableClientState(GL_COLOR_ARRAY);&lt;br /&gt; glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);&lt;br /&gt; &lt;br /&gt; // draw the ellipse&lt;br /&gt; glLoadIdentity();&lt;br /&gt; glTranslatef(ellipseData.pos.x, ellipseData.pos.y, 0.0f);&lt;br /&gt; glRotatef(ellipseData.rotation, 0.0f, 0.0f, 1.0f);&lt;br /&gt; glVertexPointer(2, GL_FLOAT, 0, ellipseVertices);&lt;br /&gt; glColorPointer(4, GL_UNSIGNED_BYTE, 0, ellipseColors);&lt;br /&gt; glEnableClientState(GL_VERTEX_ARRAY);&lt;br /&gt; glEnableClientState(GL_COLOR_ARRAY);&lt;br /&gt; glDrawArrays(GL_TRIANGLE_FAN, 0, 360);  // the ellipse has 360 vertices&lt;br /&gt; &lt;br /&gt; // control the square rotation&lt;br /&gt; if (!squareData.rotstop) {&lt;br /&gt;  squareData.rotation += squareData.rotspeed; &lt;br /&gt;  if(squareData.rotation &gt; 360.0f) &lt;br /&gt;   squareData.rotation -= 360.0f;&lt;br /&gt;  else if(squareData.rotation &lt; -360.0f) &lt;br /&gt;   squareData.rotation += 360.0f;&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt; // control the ellipse rotation&lt;br /&gt; if (!ellipseData.rotstop) {&lt;br /&gt;  ellipseData.rotation += ellipseData.rotspeed; &lt;br /&gt;  if(ellipseData.rotation &gt; 360.0f) &lt;br /&gt;   ellipseData.rotation -= 360.0f;&lt;br /&gt;  else if(ellipseData.rotation &lt; -360.0f) &lt;br /&gt;   ellipseData.rotation += 360.0f; &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; // control the square scaling&lt;br /&gt; if (squareData.scalestart &amp;&amp; squareData.scale &lt;= kMaximumScale) {&lt;br /&gt;  GLfloat pinchDelta = squareData.pinchDistance - squareData.pinchDistanceShown;&lt;br /&gt;  if (squareData.pinchDistance != 0.0f) {&lt;br /&gt;   squareData.scale += pinchDelta/30;&lt;br /&gt;   squareData.pinchDistanceShown = squareData.pinchDistance;&lt;br /&gt;   if (squareData.scale &gt;= kMaximumScale) {&lt;br /&gt;    squareData.scale = kMaximumScale;&lt;br /&gt;    squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;    squareData.scalestart = NO;&lt;br /&gt;   } else if (squareData.scale &lt;= 1.0f) {&lt;br /&gt;    squareData.scale = 1.0f;&lt;br /&gt;    squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;    squareData.scalestart = NO;&lt;br /&gt;   }&lt;br /&gt;   DEBUGLOG(@"scale is %.2f",squareData.scale);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; // control the ellipse movement&lt;br /&gt;#if TARGET_IPHONE_SIMULATOR&lt;br /&gt; ellipseData.pos.x += moveX;&lt;br /&gt; if (ellipseData.pos.x &gt;= 290.f) {&lt;br /&gt;  moveX = -2.0f;&lt;br /&gt; }&lt;br /&gt; else if (ellipseData.pos.x &lt;= 30.f) {&lt;br /&gt;  moveX = 2.0f;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; ellipseData.pos.y += moveY;&lt;br /&gt; if (ellipseData.pos.y &gt;= 450.f) {&lt;br /&gt;  moveY = -1.5f;&lt;br /&gt; }&lt;br /&gt; else if (ellipseData.pos.y &lt;= 55.f) {&lt;br /&gt;  moveY = 3.5f;&lt;br /&gt; }&lt;br /&gt;#else&lt;br /&gt; ellipseData.pos.x += moveX;&lt;br /&gt; if (accel[0] &gt; -0.1 &amp; accel[0] &lt; 0.1 ) {&lt;br /&gt;   moveX = 0.0f;&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  moveX = 10.0f * accel[0];&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; ellipseData.pos.y += moveY;&lt;br /&gt; if (accel[1] &gt; -0.1 &amp; accel[1] &lt; 0.1 ) {&lt;br /&gt;   moveY = 0.0f;&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  moveY = -10.0f * accel[1];&lt;br /&gt; }&lt;br /&gt;#endif&lt;br /&gt; if (ellipseData.pos.x &gt;= 290.f) {&lt;br /&gt;  ellipseData.pos.x = 290.0f;&lt;br /&gt; }&lt;br /&gt; else if (ellipseData.pos.x &lt;= 30.f) {&lt;br /&gt;  ellipseData.pos.x = 30.0f;&lt;br /&gt; }&lt;br /&gt; if (ellipseData.pos.y &gt;= 450.f) {&lt;br /&gt;  ellipseData.pos.y = 450.0f;&lt;br /&gt; }&lt;br /&gt; else if (ellipseData.pos.y &lt;= 55.f) {&lt;br /&gt;  ellipseData.pos.y = 55.0f;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);&lt;br /&gt;    [context presentRenderbuffer:GL_RENDERBUFFER_OES];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration&lt;br /&gt;{&lt;br /&gt; /*&lt;br /&gt;  The meaning of acceleration values for firmware 2.x&lt;br /&gt;  acceleration.x = Roll.  It corresponds to roll, or rotation around the axis that runs from your home button to your earpiece. &lt;br /&gt;  Values vary from 1.0 (rolled all the way to the right) to -1.0 (rolled all the way to the left).&lt;br /&gt;  &lt;br /&gt;  acceleration.y = Pitch. Place your iPhone on the table and mentally draw a horizontal line about half-way down the screen. &lt;br /&gt;  That's the axis around which the Y value rotates. &lt;br /&gt;  Values go from 1.0 (the headphone jack straight down) to -1.0 (the headphone jack straight up).&lt;br /&gt;  &lt;br /&gt;  acceleration.z = Face up/face down. &lt;br /&gt;  It refers to whether your iPhone is face up (-1.0) or face down (1.0). &lt;br /&gt;  When placed on it side, either the side with the volume controls and ringer switch, or the side directly opposite&lt;br /&gt;  , the Z value equates to 0.0.&lt;br /&gt;  */&lt;br /&gt; &lt;br /&gt; //Use a basic low-pass filter in the accelerometer values&lt;br /&gt; accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);&lt;br /&gt; accel[1] = acceleration.y * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);&lt;br /&gt; accel[2] = acceleration.z * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);&lt;br /&gt; &lt;br /&gt;#ifdef DEBUGSCREEN&lt;br /&gt; textView.text = [NSString stringWithFormat:&lt;br /&gt;       @"X (roll, %4.1f%%): %f\nY (pitch %4.1f%%): %f\nZ (%4.1f%%) : %f",&lt;br /&gt;       100.0 - (accel[0] + 1.0) * 50.0, accel[0], &lt;br /&gt;       100.0 - (accel[1] + 1.0) * 50.0, accel[1], &lt;br /&gt;       100.0 - (accel[2] + 1.0) * 50.0, accel[2]&lt;br /&gt;       ];&lt;br /&gt;#endif&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)layoutSubviews {&lt;br /&gt;    [EAGLContext setCurrentContext:context];&lt;br /&gt;    [self destroyFramebuffer];&lt;br /&gt;    [self createFramebuffer];&lt;br /&gt;    [self drawView];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (BOOL)createFramebuffer {&lt;br /&gt;    &lt;br /&gt;    glGenFramebuffersOES(1, &amp;viewFramebuffer);&lt;br /&gt;    glGenRenderbuffersOES(1, &amp;viewRenderbuffer);&lt;br /&gt;    &lt;br /&gt;    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);&lt;br /&gt;    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);&lt;br /&gt;    [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];&lt;br /&gt;    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);&lt;br /&gt;    &lt;br /&gt;    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;backingWidth);&lt;br /&gt;    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;backingHeight);&lt;br /&gt;    &lt;br /&gt;    if (USE_DEPTH_BUFFER) {&lt;br /&gt;        glGenRenderbuffersOES(1, &amp;depthRenderbuffer);&lt;br /&gt;        glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);&lt;br /&gt;        glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);&lt;br /&gt;        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {&lt;br /&gt;        DEBUGLOG(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));&lt;br /&gt;        return NO;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)destroyFramebuffer {&lt;br /&gt;    &lt;br /&gt;    glDeleteFramebuffersOES(1, &amp;viewFramebuffer);&lt;br /&gt;    viewFramebuffer = 0;&lt;br /&gt;    glDeleteRenderbuffersOES(1, &amp;viewRenderbuffer);&lt;br /&gt;    viewRenderbuffer = 0;&lt;br /&gt;    &lt;br /&gt;    if(depthRenderbuffer) {&lt;br /&gt;        glDeleteRenderbuffersOES(1, &amp;depthRenderbuffer);&lt;br /&gt;        depthRenderbuffer = 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)startAnimation {&lt;br /&gt;    self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)stopAnimation {&lt;br /&gt;    self.animationTimer = nil;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)setAnimationTimer:(NSTimer *)newTimer {&lt;br /&gt;    [animationTimer invalidate];&lt;br /&gt;    animationTimer = newTimer;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)setAnimationInterval:(NSTimeInterval)interval {&lt;br /&gt;    &lt;br /&gt;    animationInterval = interval;&lt;br /&gt;    if (animationTimer) {&lt;br /&gt;        [self stopAnimation];&lt;br /&gt;        [self startAnimation];&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)dealloc {&lt;br /&gt;    &lt;br /&gt;    [self stopAnimation];&lt;br /&gt;    &lt;br /&gt;    if ([EAGLContext currentContext] == context) {&lt;br /&gt;        [EAGLContext setCurrentContext:nil];&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    [context release];  &lt;br /&gt;    [super dealloc];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7572458111799403794?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7572458111799403794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7572458111799403794' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7572458111799403794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7572458111799403794'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/04/opengl-es-for-iphone-part-3-with.html' title='OpenGL ES for iPhone : Part 3 with Accelerometer control'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_3LRNVfBfliQ/SdnfbfBtByI/AAAAAAAAAs0/PNP1IV0AbdY/s72-c/opengl_p3a.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-8878423708237044723</id><published>2009-04-05T09:59:00.057+08:00</published><updated>2009-04-08T10:14:05.642+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenGL ES'/><title type='text'>OpenGL ES for iPhone : Part 2 with touch controls</title><content type='html'>We will continue to explore OpenGL ES for iPhone by interacting with input controls.  This tutorial is for iPhone Development Environment, so the touch screen control is the major and fun part to play with.&lt;br /&gt;&lt;br /&gt;In this tutorial, we will draw two objects using OpenGL ES and implement touch controls to drag and move an object around the screen and also to pinch and resize the object independently.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdgfFEHYbTI/AAAAAAAAAsE/9hF5iQom4mo/s1600-h/opengl_t2.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 215px; height: 400px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdgfFEHYbTI/AAAAAAAAAsE/9hF5iQom4mo/s400/opengl_t2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321037131602750770" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Similar to the first tutorial, we need to create a new project using the &lt;span style="font-style:italic;"&gt;OpenGL ES Application&lt;/span&gt; template from XCode.  We want to draw a new ellipse object but there is no direct function to draw an ellipse / circle in OpenGL ES, so we need to use a loop to calculate the vertices as below.  &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1) Draw an ellipse / a circle&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We use degreesToRadians, cos and sin functions to calculate the required vertices positions.  If you want a circle, just put yradius = xradius.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;GLfloat ellipseVertices[720];&lt;br /&gt;&lt;br /&gt;// calculate the vertices of ellipse&lt;br /&gt;const GLfloat xradius = 35.0f; &lt;br /&gt;const GLfloat yradius = 25.0f; &lt;br /&gt;for (int i = 0; i &lt; 720; i+=2) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ellipseVertices[i] = (cos(degreesToRadians(i)) * xradius) + 0.0f;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ellipseVertices[i+1] = (sin(degreesToRadians(i)) * yradius) + 0.0f;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and we will use GL_TRIANGLE_FAN to draw the ellipse.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;glDrawArrays(GL_TRIANGLE_FAN, 0, 360); // the ellipse has 360 vertices&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2) Create data structure&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We will create a C structure to hold the states of the two objects, so that we can independently control the status and behavior of the two objects&lt;br /&gt;&lt;code&gt;&lt;br /&gt;typedef struct&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BOOL rotstop;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// stop self rotation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BOOL touchInside;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// finger tap inside of the object ? &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BOOL scalestart;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// start to scale the obejct ?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CGPoint pos; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// position of the object on the screen&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CGPoint startTouchPosition;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Start Touch Position&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CGPoint currentTouchPosition;&amp;nbsp;&amp;nbsp;// Current Touch Position&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GLfloat pinchDistance; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// distance between two fingers pinch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GLfloat pinchDistanceShown;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// distance that have shown on screen&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GLfloat scale;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// OpenGL scale factor of the object&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GLfloat rotation;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// OpenGL rotation factor of the object&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GLfloat rotspeed; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// control rotation speed of the object&lt;br /&gt;} ObjectData;&lt;br /&gt;&lt;br /&gt;@public&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObjectData squareData;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObjectData ellipseData;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;3) Implement new method (void)setupView;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We need to create a new method so that we can do some initialization codes after the EAGLView is created.  The setupView is called after -&lt;span style="font-weight:bold;"&gt; (id)initWithCoder:(NSCoder*)coder &lt;/span&gt;method&lt;br /&gt;&lt;br /&gt;We also put some OpenGL code inside &lt;span style="font-weight:bold;"&gt;setupView&lt;/span&gt; method.  We need to separate the codes into two setupView and drawView methods, and put the initialization codes to the setupView so that it is only called once after init.  The drawing codes for after each layoutSubviews refreshes are still in &lt;span style="font-weight:bold;"&gt;drawView&lt;/span&gt; method.&lt;br /&gt;&lt;br /&gt;We also need to change the Orthographic Projection in order to match with the iPhone screen resolution 320 x 480&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Setup Orthographic Projection for the 320 x 480 of the iPhone screen&lt;br /&gt;&amp;nbsp;&amp;nbsp;glOrthof(0.0f, 320.0f, 480.0f, 0.0f, -1.0f, 1.0f);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;4) Enable multitouch and implement the touch control events&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To enable multitouch in the EAGLView, as it is not enabled by default&lt;br /&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;self.multipleTouchEnabled = YES;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and we also need to implement these standard four touch control methods for EAGLView in order to handle drag and pinch&lt;br /&gt;&lt;code&gt;&lt;br /&gt;- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event&lt;br /&gt;It sends the touchesBegan:withEvent: message when one or more fingers touch down on the screen.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;We record the starting position of the pinch and drag here&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event&lt;br /&gt;It sends the touchesMoved:withEvent: message when one or more fingers move.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;We handle the pinch and drag gestures here&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event&lt;br /&gt;It sends the touchesEnded:withEvent: message when one or more fingers lift up from the screen.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;We reset the status of the touch controls when all fingers are lifted up&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event&lt;br /&gt;It sends the touchesCancelled:withEvent: message when the touch sequence is cancelled by a system event, such as an incoming phone call.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;5) Control the moving and scaling of OpenGL ES objects independently&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We have the following codes to draw the objects in OpenGL ES and by changing the variables *&lt;span style="font-weight:bold;"&gt;.rotation&lt;/span&gt;, &lt;span style="font-weight:bold;"&gt;*.scale&lt;/span&gt; of the 2 objects through the touch control events, we can change the location and scale of the 2 objects independently.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// draw the square&lt;br /&gt;&amp;nbsp;&amp;nbsp;glLoadIdentity();&lt;br /&gt;&amp;nbsp;&amp;nbsp;glTranslatef(squareData.pos.x, squareData.pos.y, 0.0f);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glRotatef(squareData.rotation, 0.0f, 0.0f, 1.0f);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glScalef(squareData.scale, squareData.scale, 1.0f);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glVertexPointer(2, GL_FLOAT, 0, squareVertices);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glEnableClientState(GL_VERTEX_ARRAY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glEnableClientState(GL_COLOR_ARRAY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;// draw the ellipse&lt;br /&gt;&amp;nbsp;&amp;nbsp;glLoadIdentity();&lt;br /&gt;&amp;nbsp;&amp;nbsp;glTranslatef(ellipseData.pos.x, ellipseData.pos.y, 0.0f);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glRotatef(ellipseData.rotation, 0.0f, 0.0f, 1.0f);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glVertexPointer(2, GL_FLOAT, 0, ellipseVertices);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glColorPointer(4, GL_UNSIGNED_BYTE, 0, ellipseColors);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glEnableClientState(GL_VERTEX_ARRAY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glEnableClientState(GL_COLOR_ARRAY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;glDrawArrays(GL_TRIANGLE_FAN, 0, 360);&amp;nbsp;&amp;nbsp;// the ellipse has 360 vertices&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;6) Enable NSLog for Debug build and disable for Release build&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use the following define to turnon NSLog output for Debug build and turnoff for Release build&lt;br /&gt;You need to add this user-defined in Project Settings (in &lt;span style="font-weight:bold;"&gt;Debug build&lt;/span&gt; only)&lt;br /&gt;GCC_PREPROCESSOR_DEFINITIONS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DEBUGON&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sdgo6kjD0_I/AAAAAAAAAsU/H8nwL0ZGn-Q/s1600-h/debug_on.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 370px; height: 81px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sdgo6kjD0_I/AAAAAAAAAsU/H8nwL0ZGn-Q/s400/debug_on.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321047946446492658" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Or if you have an older XCode template version, it should be like this&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdnLJN2rlYI/AAAAAAAAAsk/-gSJRWz20K0/s1600-h/debug_on2.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 62px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdnLJN2rlYI/AAAAAAAAAsk/-gSJRWz20K0/s400/debug_on2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321507793913222530" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#ifdef DEBUGON&lt;br /&gt;#define DEBUGLOG if (DEBUGON) NSLog&lt;br /&gt;#else&lt;br /&gt;#define DEBUGLOG&lt;br /&gt;#endif&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then you should use DEBUGLOG() instead of NSLog() in your code.  Another hint is that you can define DEBUGLOG1, DEBUGLOG2,... etc, in this case, you can turn on / off individual sections of NSLog.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;7) The source codes are here&lt;/span&gt;, you just need to create a new project from &lt;span style="font-style:italic;"&gt;OpenGL ES Application&lt;/span&gt; template of XCode and copy the source codes of EAGLView.h and EAGLView.m from below and paste them for Build &amp; Go in XCode.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SdghqFAVDCI/AAAAAAAAAsM/GMTiRaDo44c/s1600-h/opengles_template.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 113px; height: 113px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SdghqFAVDCI/AAAAAAAAAsM/GMTiRaDo44c/s400/opengles_template.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321039966520020002" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We did not implement the ellipse object to move, may be it's your turn to explore and enhance it.  Feel free to add double-tap or multi-fingers swipe controls or add any new objects to the project.  Enjoy OpenGL ES coding in iPhone !&lt;br /&gt;&lt;br /&gt;P.S. In case you weren’t already aware, this is how to &lt;span style="font-weight:bold;"&gt;emulate multi-touch in the iPhone Simulator&lt;/span&gt; that accompanies the iPhone SDK.&lt;br /&gt;&lt;br /&gt;-&lt;span style="font-weight:bold;"&gt; Option-Click&lt;/span&gt;: Allows you to pinch in and out.&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;Option-Shift-Click&lt;/span&gt;: Allows you to perform a two-fingers drag.&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.h &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  EAGLView.h&lt;br /&gt;//  OpenGL ES Tutorial - Part 2 by javacom&lt;br /&gt;&lt;br /&gt;// To enable Debug NSLog, add GCC_PREPROCESSOR_DEFINITIONS DEBUGON in Project Settings for Debug Build Only and replace NSLog() with DEBUGLOG()&lt;br /&gt;#ifdef DEBUGON&lt;br /&gt;#define DEBUGLOG if (DEBUGON) NSLog&lt;br /&gt;#else&lt;br /&gt;#define DEBUGLOG&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGL.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/ES1/gl.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/ES1/glext.h&amp;gt;&lt;br /&gt;&lt;br /&gt;typedef struct&lt;br /&gt;{&lt;br /&gt; BOOL rotstop;                   // stop self rotation&lt;br /&gt; BOOL touchInside;               // finger tap inside of the object ? &lt;br /&gt; BOOL scalestart;                // start to scale the obejct ?&lt;br /&gt; CGPoint pos;                    // position of the object on the screen&lt;br /&gt; CGPoint startTouchPosition;     // Start Touch Position&lt;br /&gt; CGPoint currentTouchPosition;   // Current Touch Position&lt;br /&gt; GLfloat pinchDistance;          // distance between two fingers pinch&lt;br /&gt; GLfloat pinchDistanceShown;     // distance that have shown on screen&lt;br /&gt; GLfloat scale;                  // OpenGL scale factor of the object&lt;br /&gt; GLfloat rotation;               // OpenGL rotation factor of the object&lt;br /&gt; GLfloat rotspeed;               // control rotation speed of the object&lt;br /&gt;} ObjectData;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.&lt;br /&gt;The view content is basically an EAGL surface you render your OpenGL scene into.&lt;br /&gt;Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.&lt;br /&gt;*/&lt;br /&gt;@interface EAGLView : UIView {&lt;br /&gt;    &lt;br /&gt;@private&lt;br /&gt;    /* The pixel dimensions of the backbuffer */&lt;br /&gt;    GLint backingWidth;&lt;br /&gt;    GLint backingHeight;&lt;br /&gt;    &lt;br /&gt;    EAGLContext *context;&lt;br /&gt;    &lt;br /&gt;    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */&lt;br /&gt;    GLuint viewRenderbuffer, viewFramebuffer;&lt;br /&gt;    &lt;br /&gt;    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */&lt;br /&gt;    GLuint depthRenderbuffer;&lt;br /&gt;    &lt;br /&gt;    NSTimer *animationTimer;&lt;br /&gt;    NSTimeInterval animationInterval;&lt;br /&gt;&lt;br /&gt;@public&lt;br /&gt; ObjectData squareData;&lt;br /&gt; ObjectData ellipseData;&lt;br /&gt; GLfloat ellipseVertices[720];&lt;br /&gt; CGFloat initialDistance;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property NSTimeInterval animationInterval;&lt;br /&gt;&lt;br /&gt;@property (nonatomic) ObjectData squareData;&lt;br /&gt;@property (nonatomic) ObjectData ellipseData;&lt;br /&gt;@property CGFloat initialDistance;&lt;br /&gt;&lt;br /&gt;- (void)startAnimation;&lt;br /&gt;- (void)stopAnimation;&lt;br /&gt;- (void)drawView;&lt;br /&gt;- (void)setupView;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; EAGLView.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  EAGLView.m&lt;br /&gt;//  OpenGL ES Tutorial - Part 2 by javacom&lt;br /&gt;//&lt;br /&gt;#import &amp;lt;QuartzCore/QuartzCore.h&amp;gt;&lt;br /&gt;#import &amp;lt;OpenGLES/EAGLDrawable.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#import "EAGLView.h"&lt;br /&gt;&lt;br /&gt;#include &amp;lt;math.h&amp;gt;&lt;br /&gt;&lt;br /&gt;// Macros&lt;br /&gt;#define degreesToRadians(__ANGLE__) (M_PI * (__ANGLE__) / 180.0)&lt;br /&gt;#define radiansToDegrees(__ANGLE__) (180.0 * (__ANGLE__) / M_PI)&lt;br /&gt;&lt;br /&gt;CGFloat distanceBetweenPoints (CGPoint first, CGPoint second) {&lt;br /&gt; CGFloat deltaX = second.x - first.x;&lt;br /&gt; CGFloat deltaY = second.y - first.y;&lt;br /&gt; return sqrt(deltaX*deltaX + deltaY*deltaY );&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;CGFloat angleBetweenPoints(CGPoint first, CGPoint second) {&lt;br /&gt; // atan((top - bottom)/(right - left))&lt;br /&gt; CGFloat rads = atan((second.y - first.y) / (first.x - second.x));&lt;br /&gt; return radiansToDegrees(rads);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint line2End) {&lt;br /&gt; &lt;br /&gt; CGFloat a = line1End.x - line1Start.x;&lt;br /&gt; CGFloat b = line1End.y - line1Start.y;&lt;br /&gt; CGFloat c = line2End.x - line2Start.x;&lt;br /&gt; CGFloat d = line2End.y - line2Start.y;&lt;br /&gt; &lt;br /&gt; CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));&lt;br /&gt; &lt;br /&gt; return radiansToDegrees(rads);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#define USE_DEPTH_BUFFER 0&lt;br /&gt;&lt;br /&gt;#define kMinimumTouchLength 30&lt;br /&gt;#define kMaximumScale 7.0f&lt;br /&gt;#define kMinimumPinchDelta 15&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// A class extension to declare private methods&lt;br /&gt;@interface EAGLView ()&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) EAGLContext *context;&lt;br /&gt;@property (nonatomic, assign) NSTimer *animationTimer;&lt;br /&gt;&lt;br /&gt;- (BOOL) createFramebuffer;&lt;br /&gt;- (void) destroyFramebuffer;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@implementation EAGLView&lt;br /&gt;&lt;br /&gt;@synthesize context;&lt;br /&gt;@synthesize animationTimer;&lt;br /&gt;@synthesize animationInterval;&lt;br /&gt;@synthesize squareData;&lt;br /&gt;@synthesize ellipseData;&lt;br /&gt;@synthesize initialDistance;&lt;br /&gt;&lt;br /&gt;// You must implement this method&lt;br /&gt;+ (Class)layerClass {&lt;br /&gt;    return [CAEAGLLayer class];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:&lt;br /&gt;- (id)initWithCoder:(NSCoder*)coder {&lt;br /&gt;    &lt;br /&gt;    if ((self = [super initWithCoder:coder])) {&lt;br /&gt;    &lt;br /&gt;        // Get the layer&lt;br /&gt;        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;&lt;br /&gt;        &lt;br /&gt;        eaglLayer.opaque = YES;&lt;br /&gt;        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:&lt;br /&gt;                                        [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];&lt;br /&gt;        &lt;br /&gt;        context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];&lt;br /&gt;        &lt;br /&gt;        if (!context || ![EAGLContext setCurrentContext:context]) {&lt;br /&gt;            [self release];&lt;br /&gt;            return nil;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        animationInterval = 1.0 / 60.0;&lt;br /&gt;  [self setupView];&lt;br /&gt;    }&lt;br /&gt;    return self;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// These are four methods touchesBegan, touchesMoved, touchesEnded, touchesCancelled and use to notify about touches and gestures&lt;br /&gt;&lt;br /&gt;- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt;/*&lt;br /&gt; NSUInteger numTaps = [[touches anyObject] tapCount];  // number of taps&lt;br /&gt; NSUInteger numTouches = [touches count];              // number of touches&lt;br /&gt;*/ &lt;br /&gt; UITouch *touch = [[touches allObjects] objectAtIndex:0];&lt;br /&gt;&lt;br /&gt; DEBUGLOG(@"TouchBegan event counts = %d ",[[event touchesForView:self] count]);&lt;br /&gt; DEBUGLOG(@"TouchBegan tounches counts = %d ",[touches count]);&lt;br /&gt; if ([touches count]== 2) {&lt;br /&gt;  NSArray *twoTouches = [touches allObjects];&lt;br /&gt;  UITouch *first = [twoTouches objectAtIndex:0];&lt;br /&gt;  UITouch *second = [twoTouches objectAtIndex:1];&lt;br /&gt;  initialDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);  &lt;br /&gt;  squareData.rotstop = YES;&lt;br /&gt;  squareData.touchInside = NO;&lt;br /&gt; }&lt;br /&gt; else if ([touches count]==[[event touchesForView:self] count] &amp; [[event touchesForView:self] count] == 1) {&lt;br /&gt;  squareData.startTouchPosition = [touch locationInView:self];&lt;br /&gt;  if (distanceBetweenPoints([touch locationInView:self], squareData.pos) &lt;= kMinimumTouchLength * squareData.scale) {&lt;br /&gt;   DEBUGLOG(@"Square Touch at %.2f, %.2f ",squareData.pos.x,squareData.pos.y);&lt;br /&gt;   squareData.rotstop = YES;&lt;br /&gt;   squareData.touchInside = YES;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; UITouch *touch = [[touches allObjects] objectAtIndex:0];&lt;br /&gt; squareData.currentTouchPosition = [touch locationInView:self];&lt;br /&gt; if ([touches count]== 2) {&lt;br /&gt;  NSArray *twoTouches = [touches allObjects];&lt;br /&gt;  UITouch *first = [twoTouches objectAtIndex:0];&lt;br /&gt;  UITouch *second = [twoTouches objectAtIndex:1];&lt;br /&gt;  &lt;br /&gt;  // Calculate the distance bewtween the two fingers(touches) to determine the pinch distance&lt;br /&gt;  CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);&lt;br /&gt;  &lt;br /&gt;  squareData.rotstop = YES;&lt;br /&gt;  squareData.touchInside = NO;&lt;br /&gt;&lt;br /&gt;  if (initialDistance == 0.0f)&lt;br /&gt;   initialDistance = currentDistance; &lt;br /&gt;  if (currentDistance - initialDistance &gt; kMinimumPinchDelta) {&lt;br /&gt;   squareData.pinchDistance = currentDistance - initialDistance;&lt;br /&gt;   squareData.scalestart = YES;&lt;br /&gt;   DEBUGLOG(@"Outward Pinch %.2f", squareData.pinchDistance);&lt;br /&gt;  }&lt;br /&gt;  else if (initialDistance - currentDistance &gt; kMinimumPinchDelta) {&lt;br /&gt;   squareData.pinchDistance = currentDistance - initialDistance;&lt;br /&gt;   squareData.scalestart = YES;&lt;br /&gt;   DEBUGLOG(@"Inward Pinch %.2f", squareData.pinchDistance);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; else if ([touches count]==[[event touchesForView:self] count] &amp; [[event touchesForView:self] count] == 1) {&lt;br /&gt;  if (squareData.touchInside) {&lt;br /&gt;   // Only move the square to new position when touchBegan is inside the square&lt;br /&gt;   squareData.pos.x = [touch locationInView:self].x;&lt;br /&gt;   squareData.pos.y = [touch locationInView:self].y;&lt;br /&gt;   DEBUGLOG(@"Square Move to %.2f, %.2f ",squareData.pos.x,squareData.pos.y);&lt;br /&gt;   squareData.rotstop = YES;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; if ([touches count] == [[event touchesForView:self] count]) {&lt;br /&gt;  initialDistance = squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;  squareData.rotstop = squareData.touchInside = squareData.scalestart = NO;&lt;br /&gt;  DEBUGLOG(@"touchesEnded, all fingers up");&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  initialDistance = squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;  squareData.scalestart = NO;&lt;br /&gt;  DEBUGLOG(@"touchesEnded");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {&lt;br /&gt; initialDistance = squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt; squareData.rotstop = squareData.touchInside = squareData.scalestart = NO;&lt;br /&gt; DEBUGLOG(@"touchesCancelled"); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)setupView {  // new method for intialisation of variables and states&lt;br /&gt; &lt;br /&gt; // Enable Multi Touch of the view&lt;br /&gt; self.multipleTouchEnabled = YES;&lt;br /&gt; &lt;br /&gt; // Initialise square data&lt;br /&gt; squareData.rotation = squareData.pinchDistance = squareData.pinchDistanceShown = 0.0f;&lt;br /&gt; ellipseData.rotation = 0.0f;&lt;br /&gt; squareData.scale = 1.0f;&lt;br /&gt; squareData.rotstop = squareData.touchInside = squareData.scalestart = NO;&lt;br /&gt; squareData.pos.x = 160.0f;&lt;br /&gt; squareData.pos.y = 240.0f; &lt;br /&gt; squareData.pinchDistance = 0.0f;&lt;br /&gt; squareData.rotspeed = 1.0f;&lt;br /&gt;&lt;br /&gt; // Initialise ellipse data&lt;br /&gt; ellipseData.rotation = 0.0f;&lt;br /&gt; ellipseData.rotstop = ellipseData.touchInside = ellipseData.scalestart = NO;&lt;br /&gt; ellipseData.pos.x = 160.0f;&lt;br /&gt; ellipseData.pos.y = 100.0f; &lt;br /&gt; ellipseData.rotspeed = -4.0f;&lt;br /&gt;&lt;br /&gt; // calculate the vertices of ellipse&lt;br /&gt; const GLfloat xradius = 35.0f; &lt;br /&gt; const GLfloat yradius = 25.0f; &lt;br /&gt; for (int i = 0; i &lt; 720; i+=2) {&lt;br /&gt;  ellipseVertices[i] = (cos(degreesToRadians(i)) * xradius) + 0.0f;&lt;br /&gt;  ellipseVertices[i+1] = (sin(degreesToRadians(i)) * yradius) + 0.0f;&lt;br /&gt;  DEBUGLOG(@"ellipseVertices[v%d] %.1f, %.1f",i, ellipseVertices[i], ellipseVertices[i+1]);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; // setup the projection matrix&lt;br /&gt; glMatrixMode(GL_PROJECTION);&lt;br /&gt; glLoadIdentity();&lt;br /&gt; &lt;br /&gt; // Setup Orthographic Projection for the 320 x 480 of the iPhone screen&lt;br /&gt; glOrthof(0.0f, 320.0f, 480.0f, 0.0f, -1.0f, 1.0f);&lt;br /&gt; glMatrixMode(GL_MODELVIEW);&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)drawView {&lt;br /&gt;    &lt;br /&gt;    // Define the square vertices&lt;br /&gt; const GLfloat squareVertices[] = {&lt;br /&gt;        -20.0f, -20.0f,&lt;br /&gt;        20.0f,  -20.0f,&lt;br /&gt;        -20.0f,  20.0f,&lt;br /&gt;        20.0f,   20.0f,&lt;br /&gt;    };&lt;br /&gt; &lt;br /&gt;    // Define the colors of the square vertices&lt;br /&gt; const GLubyte squareColors[] = {&lt;br /&gt;        255, 255,   0, 255,&lt;br /&gt;        0,   255, 255, 255,&lt;br /&gt;        0,     0,   0,   0,&lt;br /&gt;        255,   0, 255, 255,&lt;br /&gt;    };&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; // Define the colors of the ellipse vertices&lt;br /&gt; const GLubyte ellipseColors[] = {&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;        233,  85,   85, 255,&lt;br /&gt;    };&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    [EAGLContext setCurrentContext:context];&lt;br /&gt;    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);&lt;br /&gt;    glViewport(0, 0, backingWidth, backingHeight);&lt;br /&gt;    &lt;br /&gt; // Clear background color&lt;br /&gt;    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);&lt;br /&gt;    glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt; &lt;br /&gt; // draw the square&lt;br /&gt; glLoadIdentity();&lt;br /&gt; glTranslatef(squareData.pos.x, squareData.pos.y, 0.0f);&lt;br /&gt; glRotatef(squareData.rotation, 0.0f, 0.0f, 1.0f);&lt;br /&gt; glScalef(squareData.scale, squareData.scale, 1.0f);&lt;br /&gt; glVertexPointer(2, GL_FLOAT, 0, squareVertices);&lt;br /&gt; glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);&lt;br /&gt; glEnableClientState(GL_VERTEX_ARRAY);&lt;br /&gt; glEnableClientState(GL_COLOR_ARRAY);&lt;br /&gt; glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);&lt;br /&gt; &lt;br /&gt; // draw the ellipse&lt;br /&gt; glLoadIdentity();&lt;br /&gt; glTranslatef(ellipseData.pos.x, ellipseData.pos.y, 0.0f);&lt;br /&gt; glRotatef(ellipseData.rotation, 0.0f, 0.0f, 1.0f);&lt;br /&gt; glVertexPointer(2, GL_FLOAT, 0, ellipseVertices);&lt;br /&gt; glColorPointer(4, GL_UNSIGNED_BYTE, 0, ellipseColors);&lt;br /&gt; glEnableClientState(GL_VERTEX_ARRAY);&lt;br /&gt; glEnableClientState(GL_COLOR_ARRAY);&lt;br /&gt; glDrawArrays(GL_TRIANGLE_FAN, 0, 360);  // the ellipse has 360 vertices&lt;br /&gt;&lt;br /&gt; // control the square rotation&lt;br /&gt; if (!squareData.rotstop) {&lt;br /&gt;  squareData.rotation += squareData.rotspeed; &lt;br /&gt;  if(squareData.rotation &gt; 360.0f) &lt;br /&gt;   squareData.rotation -= 360.0f;&lt;br /&gt;  else if(squareData.rotation &lt; -360.0f) &lt;br /&gt;   squareData.rotation += 360.0f;&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt; // control the ellipse rotation&lt;br /&gt; if (!ellipseData.rotstop) {&lt;br /&gt;  ellipseData.rotation += ellipseData.rotspeed; &lt;br /&gt;  if(ellipseData.rotation &gt; 360.0f) &lt;br /&gt;   ellipseData.rotation -= 360.0f;&lt;br /&gt;  else if(ellipseData.rotation &lt; -360.0f) &lt;br /&gt;   ellipseData.rotation += 360.0f; &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; // control the square scaling&lt;br /&gt; if (squareData.scalestart &amp;&amp; squareData.scale &lt;= kMaximumScale) {&lt;br /&gt;  GLfloat pinchDelta = squareData.pinchDistance - squareData.pinchDistanceShown;&lt;br /&gt;  if (squareData.pinchDistance != 0.0f) {&lt;br /&gt;   squareData.scale += pinchDelta/30;&lt;br /&gt;   squareData.pinchDistanceShown = squareData.pinchDistance;&lt;br /&gt;   if (squareData.scale &gt;= kMaximumScale) {&lt;br /&gt;    squareData.scale = kMaximumScale;&lt;br /&gt;    squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;    squareData.scalestart = NO;&lt;br /&gt;   } else if (squareData.scale &lt;= 1.0f) {&lt;br /&gt;    squareData.scale = 1.0f;&lt;br /&gt;    squareData.pinchDistanceShown = squareData.pinchDistance = 0.0f;&lt;br /&gt;    squareData.scalestart = NO;&lt;br /&gt;   }&lt;br /&gt;   DEBUGLOG(@"scale is %.2f",squareData.scale);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);&lt;br /&gt;    [context presentRenderbuffer:GL_RENDERBUFFER_OES];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)layoutSubviews {&lt;br /&gt;    [EAGLContext setCurrentContext:context];&lt;br /&gt;    [self destroyFramebuffer];&lt;br /&gt;    [self createFramebuffer];&lt;br /&gt;    [self drawView];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (BOOL)createFramebuffer {&lt;br /&gt;    &lt;br /&gt;    glGenFramebuffersOES(1, &amp;viewFramebuffer);&lt;br /&gt;    glGenRenderbuffersOES(1, &amp;viewRenderbuffer);&lt;br /&gt;    &lt;br /&gt;    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);&lt;br /&gt;    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);&lt;br /&gt;    [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];&lt;br /&gt;    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);&lt;br /&gt;    &lt;br /&gt;    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;backingWidth);&lt;br /&gt;    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;backingHeight);&lt;br /&gt;    &lt;br /&gt;    if (USE_DEPTH_BUFFER) {&lt;br /&gt;        glGenRenderbuffersOES(1, &amp;depthRenderbuffer);&lt;br /&gt;        glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);&lt;br /&gt;        glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);&lt;br /&gt;        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {&lt;br /&gt;        DEBUGLOG(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));&lt;br /&gt;        return NO;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)destroyFramebuffer {&lt;br /&gt;    &lt;br /&gt;    glDeleteFramebuffersOES(1, &amp;viewFramebuffer);&lt;br /&gt;    viewFramebuffer = 0;&lt;br /&gt;    glDeleteRenderbuffersOES(1, &amp;viewRenderbuffer);&lt;br /&gt;    viewRenderbuffer = 0;&lt;br /&gt;    &lt;br /&gt;    if(depthRenderbuffer) {&lt;br /&gt;        glDeleteRenderbuffersOES(1, &amp;depthRenderbuffer);&lt;br /&gt;        depthRenderbuffer = 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)startAnimation {&lt;br /&gt;    self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)stopAnimation {&lt;br /&gt;    self.animationTimer = nil;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)setAnimationTimer:(NSTimer *)newTimer {&lt;br /&gt;    [animationTimer invalidate];&lt;br /&gt;    animationTimer = newTimer;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)setAnimationInterval:(NSTimeInterval)interval {&lt;br /&gt;    &lt;br /&gt;    animationInterval = interval;&lt;br /&gt;    if (animationTimer) {&lt;br /&gt;        [self stopAnimation];&lt;br /&gt;        [self startAnimation];&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)dealloc {&lt;br /&gt;    &lt;br /&gt;    [self stopAnimation];&lt;br /&gt;    &lt;br /&gt;    if ([EAGLContext currentContext] == context) {&lt;br /&gt;        [EAGLContext setCurrentContext:nil];&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    [context release];  &lt;br /&gt;    [super dealloc];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-8878423708237044723?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/8878423708237044723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=8878423708237044723' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8878423708237044723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8878423708237044723'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/04/opengl-es-for-iphone-part-ii-with-touch.html' title='OpenGL ES for iPhone : Part 2 with touch controls'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/SdgfFEHYbTI/AAAAAAAAAsE/9hF5iQom4mo/s72-c/opengl_t2.png' height='72' width='72'/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7676251862696813688</id><published>2009-04-02T22:25:00.113+08:00</published><updated>2009-04-08T10:02:58.163+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenGL ES'/><title type='text'>OpenGL ES for iPhone : A Simple Tutorial Part 1</title><content type='html'>It is difficult to find a beginner's book/tutorial suitable for OpenGL ES 1.1 in iPhone Development, partly because the current version of OpenGL ES is already 2.0 (there is a book on it).   OpenGL ES 2.0 code is, unfortunately, &lt;span style="font-weight:bold;"&gt;NOT&lt;/span&gt; backward compatible with the OpenGL ES version 1.1 that iPhone use.  If you rely on the materials from OpenGL (not ES) 1.5, some functions / features are not available in OpenGL ES as well.  Upto now, there is no primer books on OpenGL ES 1.1 for iPhone Development Environment.&lt;br /&gt;&lt;br /&gt;OpenGL ES specification can be obtained here&lt;br /&gt;&lt;a href="http://www.khronos.org/opengles/spec/"&gt;http://www.khronos.org/opengles/spec/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.khronos.org/registry/gles/specs/1.1/es_full_spec.1.1.12.pdf"&gt;http://www.khronos.org/registry/gles/specs/1.1/es_full_spec.1.1.12.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The OpenGL ES is an API suitable for contrained devices,  and is derived from the OpenGL 1.5 specification.  To achieve this goal, redundancy  was removed from the OpenGL API.  For example, in OpenGL ES, only vertex arrays exist and immediate mode and display lists were removed.&lt;br /&gt;&lt;br /&gt;It is not easy to learn OpenGL ES for iPhone based on the existing available resources, so I decided to write this article based on the materials that I collected from different sources.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1) What is OpenGL ES ?&lt;/span&gt;&lt;br /&gt;OpenGL ES is an API for advanced 3D graphics targeted at handheld devices such as iPhone. In OpenGL ES, geometric objects are drawn by specifying a series of coordinate sets that include vertice attributes like position, normal color and texture coordinates. Vertice position is specified using vertex arrays.&lt;br /&gt;&lt;br /&gt;OpenGL ES is a "State Machine".  This describes the use of state variables in OpenGL ES and commands are used for querying, enabling, and disabling states.  So enabling states in different orders may have different behavior.&lt;br /&gt;&lt;br /&gt;If you have read some OpenGL (not ES) books, you would know that OpenGL ES does not use glBegin() and glEnd().  Moreover, some OpenGL Extensions are not available in iPhone as well.  For the list of supported Extensions in iPhone and iPhone Simulator, please refer to "&lt;a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/GraphicsandDrawing/GraphicsandDrawing.html#//apple_ref/doc/uid/TP40007072-CH10-SW18"&gt;Drawing With OpenGL ES&lt;/a&gt;" in iPhone Application Programming Guide from Apple.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2) How to start learning OpenGL ES ?&lt;/span&gt;&lt;br /&gt;The most easiest way is to learn Open GL ES by actual coding and running in an emulator and iPhone Simulator from the SDK is a perfect emulator to test the OpenGL ES code.  In iPhone SDK, you can create a new project from the OpenGL ES Application Template and without any modification, after you build &amp;amp; go in Simulator, you will see a colored square rotating at the middle of the screen.  If you look closely into the source code, you will notice that the rotating square is defined and created inside the  &lt;span style="font-weight:bold;"&gt;(void)drawView&lt;/span&gt; method of the source file EAGLView.m&lt;br /&gt;&lt;br /&gt;From the source code, we could learn how to do basic drawings in OpenGL ES for iPhone.  Here is the step by step tutorial and we have taken the approach to explain the existing code inside &lt;span style="font-weight:bold;"&gt;drawView()&lt;/span&gt; method first, so that you know what the code does and where to change the code if you want to mess around.  You may also consider to use the Snapshot feature of XCode which is a very good "time machine" for your XCode Project.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;3) How to specify the coordinates for a square ?&lt;/span&gt;&lt;br /&gt;&lt;code&gt;  const GLfloat squareVertices[] = {&lt;br /&gt;    -0.5f, -0.5f,    // position v0&lt;br /&gt;     0.5f, -0.5f,    // position v1&lt;br /&gt;    -0.5f,  0.5f,    // position v2&lt;br /&gt;     0.5f,  0.5f,    // position v3&lt;br /&gt;  };&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Each set of 2 floats given above specifies the x, y value of a vertex.  The x is the horizontal position, the y is the vertical position that should be.   If you give the third float number in the set, this would be z coordinate.  The more positive the z coordinate, the more out of the screen (towards you) it is.  Later tutorials, we will show you how to draw a pyramid which is a 3D model.&lt;br /&gt;&lt;br /&gt;For the vertices position of each set in the square, please refer to diagram of point (4) below.&lt;br /&gt;&lt;br /&gt;The vertices positions &lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;correspond to the different OpenGL ES Primitive Types in glDrawArrays() function&lt;/span&gt; that you will use later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;4) How to specify the colors for a square ?&lt;/span&gt;&lt;br /&gt;&lt;code&gt;  const GLubyte squareColors[] = {&lt;br /&gt;    255, 255,   0, 255,    // yellow color&lt;br /&gt;      0, 255, 255, 255,    // cyan color&lt;br /&gt;      0,   0,   0,   0,    // black color&lt;br /&gt;    255,   0, 255, 255,    // magenta color&lt;br /&gt;  };&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The colors are specified in groups of 4 given as above. The first color is red+green=yellow, the second is green+blue=cyan and the third is black and the fourth is red+blue=magenta.   The first three parameters indicate your red, green and blue values.  The larger the value, the brighter the color.   If all values are 0, you get black. If all values are 255, you get white.  The last value is the alpha value and is used for transparency. 0 is completely transparent.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdV2ib_aQXI/AAAAAAAAArk/aBUAdNEpgi8/s1600-h/coloredsquare.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 206px; height: 205px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdV2ib_aQXI/AAAAAAAAArk/aBUAdNEpgi8/s400/coloredsquare.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320288868809458034" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;5) OpenGL projection matrix &lt;span style="font-weight:bold;"&gt;glMatrixMode(GL_PROJECTION);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The next OpenGL function is glMatrixMode.  When working with OpenGL, there are various matrices that are available to work with.  These define the view and how primitives should be placed.   When transforming primitives later, the GL_MODELVIEW matrix will be used.  If the projection (how objects are viewed) need to be changed later, GL_PROJECTION matrix will be used.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;6) Identity Matrix glLoadIdentity();&lt;/span&gt;&lt;br /&gt;This is a 4 x 4 matrix with 1's on the diagonals and 0's everywhere else.  The identity matrix has the same properties as the value 1 in normal multiplication.   Any matrix that multiply by the identity matrix will stay the same.   The loading of identity matrix function glLoadIdentity() takes no parameters. We use the &lt;span style="font-weight:bold;"&gt;glLoadIdentity();&lt;/span&gt; to clear the currently modifiable matrix for future transformation commands, as these commands modify the current matrix.  Typically, we call this command before specifying projection or viewing transformations and also might call it before specifying a modeling transformation.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;7) Orthographic Projection &lt;span style="font-weight:bold;"&gt;glOrthof(left, right, bottom, top, near, far);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;There are 2 ways to view things.   One is by viewing objects in an Orthogrpahic manner and the other is viewing objects in a perspective view.   If you have ever looked down a long road, you will notice that the road gets smaller and smaller the further down you look. This is a perspective view.   In an Orthographic view, the road would remain the same width as far as you could see.  Orthographic projection runs quicker than perspective projection.  This does not mean that we should always use it though.  Sometimes you do not necessarily want depth eg. for 2D applications or games.  Here, orthographic projection is extremely useful.&lt;br /&gt;&lt;br /&gt;The glOrthof() function is used to specify orthographic projection.  This function takes 6 parameters, each explained below.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;GLfloat left &amp;amp; GLfloat right&lt;br /&gt;        These specify the values for the left and right clipping planes.&lt;br /&gt;&lt;br /&gt;GLfloat bottom &amp;amp; GLfloat top&lt;br /&gt;        These specify the values for the bottom and top clipping planes.&lt;br /&gt;&lt;br /&gt;GLfloat near &amp;amp; GLfloat far&lt;br /&gt;        These specify the drawing distance. Any objects out of this range will&lt;br /&gt;        not be displayed.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sdk8D4Tp20I/AAAAAAAAAsc/rkyI5osxS40/s1600-h/frustum.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 203px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/Sdk8D4Tp20I/AAAAAAAAAsc/rkyI5osxS40/s400/frustum.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5321350472067046210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All parameters above specify an area that will be displayed in the window.  Looking back at the vertices specified for the square, you can see that the square will be displayed in the center of the window.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;8) Rotating the square &lt;span style="font-weight:bold;"&gt;glRotatef(3.0f, 0.0f, 0.0f, 1.0f);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The rotation transformation is done using the &lt;span style="font-weight:bold;"&gt;glRotatef()&lt;/span&gt; function.  The first parameter specifies the angle in degrees to rotate the objects, positive float value means counter-clockwise direction, negative float means clockwise.  The next 3 parameters are used to specify in what axis to rotate. These specify a vector. A value of 1.0 is normally used to specify an axis. If you comment out the glRotatef() function call, you will see the square in steady position and we have numbered the vertices position in the diagram below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdV2ib_aQXI/AAAAAAAAArk/aBUAdNEpgi8/s1600-h/coloredsquare.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 206px; height: 205px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/SdV2ib_aQXI/AAAAAAAAArk/aBUAdNEpgi8/s400/coloredsquare.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320288868809458034" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;9) Clearing color for the background &lt;span style="font-weight:bold;"&gt;glClearColor(0.5f, 0.5f, 0.5f, 1.0f);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The first three parameters indicate your red, green and blue values for the background color.   The larger the value, the brighter the color. If all values are 0, you get black. If all values are 1, you get white.   The last value is the alpha value.   This is used for transparency. 1.0f is completely opaque and 0.0f is completely transparent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;10) Clearing the color buffer glClear(GL_COLOR_BUFFER_BIT);&lt;/span&gt;&lt;br /&gt;This function accepts one parameter being which buffers you want to clear.  This causes the screen to be cleared to the grey color specified in point (9) above.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;11) Set the current Vertex Array glVertexPointer(2, GL_FLOAT, 0, squareVertices);&lt;/span&gt;&lt;br /&gt;Primitives in OpenGL ES are drawn using Vertex Arrays.   You need to set the current vertices to use.  This is accomplished by using the glVertexPointer function. This function takes 4 parameters :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;GLint size&lt;br /&gt;        This specifies the number of coordinates per vertex.&lt;br /&gt;        As we had left off the 0.0f's in the square vertices above,&lt;br /&gt;        we would place a 2 here.&lt;br /&gt;        If each vertex has been specified using 3 values (x,y,z) ,&lt;br /&gt;        we would use a 3 for this parameter.&lt;br /&gt;&lt;br /&gt;GLenum type&lt;br /&gt;        specifies what data type is being used for the values in the array&lt;br /&gt;        eg. GL_BYTE, GL_SHORT, GL_FLOAT, etc.&lt;br /&gt;&lt;br /&gt;GLsizei stride&lt;br /&gt;        specifies the offset between consecutive vertices ie. how many&lt;br /&gt;        extra values exist between the end of the current vertex and&lt;br /&gt;        the beginning of the next vertex.  We do not have any extra data&lt;br /&gt;        between vertices and so we therefore pass 0 for this parameter.&lt;br /&gt;&lt;br /&gt;const GLvoid *pointer&lt;br /&gt;        The last parameter is used to specify the memory location of&lt;br /&gt;        the first value in the array of values ie. the pointer to the array.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;12)  Enable the Vertex Array &lt;span style="font-weight:bold;"&gt;glEnableClientState(GL_VERTEX_ARRAY);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Like the Vertex Array, there are a number of other arrays that will be covered.  If not all of these arrays are being used, resources can be saved by disabling the others.   All are disabled by default and so we therefore need to enable the Vertex Array.  This is done by using the glEnableClientState(GL_VERTEX_ARRAY) function.  This function takes one parameter, specifying the array that must be enabled.  We therefore pass the GL_VERTEX_ARRAY flag to enable the Vertex Array.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;13) Set the current Color Array &lt;span style="font-weight:bold;"&gt;glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Similar to Vertex Array, color array is setup by glColorPointer() function.  We pass a 4 as the first parameter to indicate that there are 4 floats per vertex.  Other parameters are similar to that of glVertexPointer().&lt;br /&gt;&lt;br /&gt;If you want to change the shading mode, you can use &lt;span style="font-weight:bold;"&gt;glShadeModel()&lt;/span&gt; function.  The default is smooth shaded &lt;span style="font-weight:bold;"&gt;glShadeModel(GL_SMOOTH)&lt;/span&gt; and the other option is flat shaded &lt;span style="font-weight:bold;"&gt;glShadeModel(GL_FLAT)&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;14) Enable the Color Array &lt;span style="font-weight:bold;"&gt;glEnableClientState(GL_COLOR_ARRAY);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The Color Array is enabled by using the glEnableClientState(GL_COLOR_ARRAY) function&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;15) Display a shape on the screen &lt;span style="font-weight:bold;"&gt;glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Finally, we need to display the shape on the iPhone screen using the glDrawArrays() function.  The parameters are as follows :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;GLenum mode&lt;br /&gt;        This is used to specify what primitive to draw. see point (16) below.&lt;br /&gt;GLint first&lt;br /&gt;        This is used to specify the starting index in the array&lt;br /&gt;        ie. how many vertices in the array to skip before starting to read them.&lt;br /&gt;        We want to start from the beginning, thus requiring a value of 0 to be passed.&lt;br /&gt;&lt;br /&gt;GLsizei count&lt;br /&gt;        This specifies how many vertices to process. We have 4 vertices&lt;br /&gt;        that we want to use. This is the value that we need to pass to the function.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;16) OpenGL Primitives&lt;/span&gt;&lt;br /&gt;The first parameter is primitive flag and OpenGL has defined the following types.  Primitives are created by specifying vertices.   These are points in 3D space which specify points on the shape.  A list of primitives are given below along with how their vertices should be placed (also refer to the diagram below).   The primitive type defined the order of the vertices are drawn.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;u&gt;Primitive Flag&lt;/u&gt;&lt;/span&gt;       &lt;span style="font-style:italic;"&gt;&lt;u&gt;Description&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;GL_POINTS            A point is placed at each vertex.&lt;br /&gt;GL_LINES             A line is drawn for every pair of vertices that are given.&lt;br /&gt;GL_LINE_STRIP        A continuous set of lines are drawn. After the first&lt;br /&gt;                     vertex, a line is drawn between every successive vertex&lt;br /&gt;                     and the vertex before it.&lt;br /&gt;GL_LINE_LOOP         This is the same as GL_LINE_STRIP except that the start and end&lt;br /&gt;                     vertices are connected as well.&lt;br /&gt;GL_TRIANGLES         For every triplet of vertices, a triangle is drawn with corners&lt;br /&gt;                     specified by the coordinates of the vertices.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It begins with v0,v1,v2 then v3,v4,v5 and so on.&lt;br /&gt;GL_TRIANGLE_STRIP    After the first 2 vertices, every successive vertex uses the&lt;br /&gt;                     previous 2 vertices to draw a triangle.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It begins with v0,v1,v2 then v1,v2,v3 then v2,v3,v4 and so on.&lt;br /&gt;GL_TRIANGLE_FAN      After the first 2 vertices, every successive vertex uses the&lt;br /&gt;                     previous vertex and the first vertex to draw a triangle.&lt;br /&gt;                     This is used to draw cone-like shapes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It begins with v0,v1,v2 then v0,v2,v3 then v0,v3,v4 and so on.&lt;br /&gt;&lt;strike&gt;GL_QUADS&lt;/strike&gt;             Draws a series of quadrilaterals (four sided polygons)&lt;br /&gt;                     beginning with v0,v1,v2,v3 then v4,v5,v6,v7 and so on&lt;br /&gt;&lt;strike&gt;GL_QUAD_STRIP&lt;/strike&gt;        Does a series of quadrilaterals beginning with&lt;br /&gt;                     v0,v1,v3,v2 then v2,v3,v5,v4 then v4,v5,v7,v6 and so on&lt;br /&gt;&lt;strike&gt;GL_POLYGON&lt;/strike&gt;           Draws a polygon using the points v0,v1,...,vn&lt;br /&gt;                     as vertices.  n must be at least 3, or nothing is drawn.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sdrassh4daI/AAAAAAAAAs8/PJHO65VEvyw/s1600-h/opengles_primitives.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 305px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sdrassh4daI/AAAAAAAAAs8/PJHO65VEvyw/s400/opengles_primitives.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321806371094033826" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;17) How to change it to a triangle, move/scale the object ?&lt;/span&gt;&lt;br /&gt;You can simply change the last parameter of glDrawArrays to 3 like below, you will see a rotating triangle.  By using the parameter 3, the code ignores the 4th position of the Array.  If you want to change the triangle position or the shape, you should change the values in the array or use transform function to move the triangle.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You can use the &lt;span style="font-weight:bold;"&gt;glTranslatef()&lt;/span&gt; function to move the triangle and the glTranslatef() function should be inserted before the glMatrixMode function as below.&lt;br /&gt;&lt;code&gt;    glTranslatef(0.25f, 0.5f, 0.0f);&lt;br /&gt;    glMatrixMode(GL_MODELVIEW);&lt;br /&gt;    glRotatef(3.0f, 0.0f, 0.0f, 1.0f);&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;We pass 3 floats to the glTranslatef() function, specifying the value to move the drawn objects in the x, y and z direction. Our first transformation is to move the triangle right 0.25 units and up 0.5 units.&lt;br /&gt;&lt;br /&gt;You can use the &lt;span style="font-weight:bold;"&gt;glScalef()&lt;/span&gt; function to scale the triangle and the glScalef() function should be inserted before the glMatrixMode function as below.  The code below reduces the size of the triangle by half. You can scale an object a different amount in each axis.  Try to experiment different values for the parameters of glScalef() function to see the effect.&lt;br /&gt;&lt;code&gt;    glScalef(0.5f, 0.5f, 0.5f);&lt;br /&gt;    glMatrixMode(GL_MODELVIEW);&lt;br /&gt;    glRotatef(3.0f, 0.0f, 0.0f, 1.0f);&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;18) Transformation: "translate first then rotate" or "rotate first then translate" ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The output of the following codes by changing the order of &lt;span style="font-weight:bold;"&gt;glTranslatef()&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;glRotatef()&lt;/span&gt; functions will be different.  You can try these codes and see the results in the Simulator.&lt;br /&gt;&lt;br /&gt;Please take note that these glTranslatef() and glRotatef() function calls are before glMatrixMode(GL_MODELVIEW);&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    glTranslatef(0.0f, 0.5f, 0.0f);        // translate first&lt;br /&gt;    glRotatef(30.0f, 0.0f, 0.0f, 1.0f);    // then rotate&lt;br /&gt;    glMatrixMode(GL_MODELVIEW);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;is different from&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    glRotatef(30.0f, 0.0f, 0.0f, 1.0f);    // rotate first&lt;br /&gt;    glTranslatef(0.0f, 0.5f, 0.0f);        // then translate&lt;br /&gt;    glMatrixMode(GL_MODELVIEW);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you try these codes above, and translate something to the right and then rotate it, you will view a rotated shape sitting on the horizontal axis. If you first rotate the object and then translate it, you will view a rotated shape that has been moved out diagonally from the origin.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;19) Transformation after glMatrixMode(GL_MODELVIEW);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Try changing the order or values of the &lt;span style="font-weight:bold;"&gt;glTranslatef()&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;glRotatef()&lt;/span&gt; functions below to see what affect each one has.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;    glMatrixMode(GL_MODELVIEW);&lt;br /&gt;    glTranslatef(0.0f, 0.05f, 0.0f);      // move the object&lt;br /&gt;    glRotatef(3.0f, 0.0f, 0.0f, 1.0f);    // rotate the object&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;20) How to change it to a polygon ?&lt;/span&gt;&lt;br /&gt;If you change these codes, you will see a rotating polygon outline as below, we have also numbered the vertices position in the diagram.&lt;br /&gt;&lt;code&gt;  const GLfloat squareVertices[] = {&lt;br /&gt;    -0.5f, -0.5f,    // position v0&lt;br /&gt;    -0.5f,  0.5f,    // position v1&lt;br /&gt;     0.0f, 0.75f,    // position v2&lt;br /&gt;     0.5f,  0.5f,    // position v3&lt;br /&gt;     0.5f, -0.5f,    // position v4&lt;br /&gt;  };&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;  const GLubyte squareColors[] = {&lt;br /&gt;    255, 255,   0, 255,    // yellow color&lt;br /&gt;      0, 255, 255, 255,    // cyan color&lt;br /&gt;      0,   0,   0,   0,    // black color&lt;br /&gt;    255,   0,   0,   1,    // red color&lt;br /&gt;    255,   0, 255, 255,    // magenta color&lt;br /&gt;  };&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  glDrawArrays(GL_LINE_LOOP, 0, 5);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3LRNVfBfliQ/SdWAmV_If_I/AAAAAAAAArs/MAmpLHxGR1Q/s1600-h/house.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 200px; height: 240px;" src="http://1.bp.blogspot.com/_3LRNVfBfliQ/SdWAmV_If_I/AAAAAAAAArs/MAmpLHxGR1Q/s400/house.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5320299931033436146" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You may notice that the primitive types for GL_QUADS, GL_QUAD_STRIP &amp;amp; GL_POLYGON are not available in OpenGL ES.  To draw the polygon as below, you need to use GL_TRIANGLE_STRIP with these codes&lt;br /&gt;&lt;br /&gt;&lt;code&gt;  const GLfloat squareVertices[] = {&lt;br /&gt;    -0.5f, -0.5f,    // position v0&lt;br /&gt;     0.5f, -0.5f,    // position v1&lt;br /&gt;    -0.5f,  0.5f,    // position v2&lt;br /&gt;     0.5f,  0.5f,    // position v3&lt;br /&gt;     0.0f,  0.75f,   // position v4&lt;br /&gt;  };&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;and&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;It does a series of triangle drawings beginning with v0, v1, v2 then v1, v2, v3 and finally v2, v3, v4.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SdwCDmh93VI/AAAAAAAAAtE/7-j0km4wbPo/s1600-h/polygon.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 220px; height: 254px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SdwCDmh93VI/AAAAAAAAAtE/7-j0km4wbPo/s400/polygon.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5322131120550960466" /&gt;&lt;/a&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7676251862696813688?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7676251862696813688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7676251862696813688' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7676251862696813688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7676251862696813688'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/04/opengl-es-for-iphone-simple-tutorial.html' title='OpenGL ES for iPhone : A Simple Tutorial Part 1'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/SdV2ib_aQXI/AAAAAAAAArk/aBUAdNEpgi8/s72-c/coloredsquare.png' height='72' width='72'/><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-8689459320462177534</id><published>2009-03-26T12:48:00.005+08:00</published><updated>2009-03-26T22:03:52.160+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='p2p bluetooth'/><title type='text'>Sample Source Code : iPhone OS 3.0 peer to peer bluetooth connectivity</title><content type='html'>Just saw a sample source code from the apple dev forum to sharing the testing the p2p bluetooth&lt;br /&gt;&lt;br /&gt;What you need to do is to create a new project from OpenGL ES Application of iPhone OS 3.0 SDK template called it BluetoothSample&lt;br /&gt;and past the codes as below and test, it should work on 2 iPhone 3G and iPod Touch 2nd gen only.&lt;br /&gt;&lt;br /&gt;Then you need to add GameKit framework to build and go&lt;br /&gt;&lt;br /&gt;The source is from Travis True&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; BluetoothSampleAppDelegate.h &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//&lt;br /&gt;//  BluetoothSampleAppDelegate.h&lt;br /&gt;//  BluetoothSample&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#import "EAGLView.h"&lt;br /&gt;#import &amp;lt;GameKit/GameKit.h&amp;gt;&lt;br /&gt;&lt;br /&gt;@interface BluetoothSampleAppDelegate : NSObject &lt;UIApplicationDelegate, GKPeerPickerControllerDelegate, GKSessionDelegate&gt; {&lt;br /&gt;    UIWindow *window;&lt;br /&gt;    EAGLView *glView;&lt;br /&gt; &lt;br /&gt; GKPeerPickerController *picker;&lt;br /&gt; GKSession *session;&lt;br /&gt; &lt;br /&gt; int myNumber;&lt;br /&gt; NSData *myData;&lt;br /&gt; UILabel *textView;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) IBOutlet UIWindow *window;&lt;br /&gt;@property (nonatomic, retain) IBOutlet EAGLView *glView;&lt;br /&gt;@property (nonatomic, retain) GKPeerPickerController *picker;&lt;br /&gt;@property (nonatomic, retain) GKSession *session;&lt;br /&gt;&lt;br /&gt;- (void)mySendData;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt; BluetoothSampleAppDelegate.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//&lt;br /&gt;//  BluetoothSampleAppDelegate.m&lt;br /&gt;//  BluetoothSample&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#import "BluetoothSampleAppDelegate.h"&lt;br /&gt;&lt;br /&gt;@implementation BluetoothSampleAppDelegate&lt;br /&gt;&lt;br /&gt;@synthesize picker;&lt;br /&gt;@synthesize session;&lt;br /&gt;@synthesize window;&lt;br /&gt;@synthesize glView;&lt;br /&gt;&lt;br /&gt;- (void)applicationDidFinishLaunching:(UIApplication *)application {&lt;br /&gt; &lt;br /&gt; // setup the text view&lt;br /&gt; myNumber = 0;&lt;br /&gt; textView = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 640.0f, 12.0f)];&lt;br /&gt; textView.text = [NSString stringWithFormat:@"myNumber: %i\n", myNumber];&lt;br /&gt; [window addSubview:textView];&lt;br /&gt; [window bringSubviewToFront:textView];&lt;br /&gt; &lt;br /&gt; // start the EAGLView&lt;br /&gt; glView.animationInterval = 1.0 / 60.0;&lt;br /&gt; [glView startAnimation];&lt;br /&gt; &lt;br /&gt; // allocate the NSData&lt;br /&gt; myData = [[NSData alloc] initWithBytes:&amp;myNumber length:sizeof(int)];&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; // allocate and setup the peer picker controller&lt;br /&gt; picker  = [[GKPeerPickerController alloc] init];&lt;br /&gt; picker.delegate = self;&lt;br /&gt; picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby | GKPeerPickerConnectionTypeOnline;&lt;br /&gt; [picker show];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)applicationWillResignActive:(UIApplication *)application {&lt;br /&gt; glView.animationInterval = 1.0 / 5.0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)applicationDidBecomeActive:(UIApplication *)application {&lt;br /&gt; glView.animationInterval = 1.0 / 60.0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type {&lt;br /&gt;    if(type == GKPeerPickerConnectionTypeOnline) {&lt;br /&gt;        [self.picker dismiss];&lt;br /&gt;        [self.picker release];&lt;br /&gt;        self.picker = nil;&lt;br /&gt;  // Display your own UI here.&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (GKSession *) peerPickerController:(GKPeerPickerController *)picker&lt;br /&gt;   sessionForConnectionType:(GKPeerPickerConnectionType)type {&lt;br /&gt; session = [[GKSession alloc] initWithSessionID:@"FR"  displayName:nil sessionMode:GKSessionModePeer];&lt;br /&gt; session.delegate = self;&lt;br /&gt; &lt;br /&gt; return session;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state {&lt;br /&gt; switch (state) {&lt;br /&gt;  case GKPeerStateConnected:&lt;br /&gt;   [self.session setDataReceiveHandler :self withContext:nil];&lt;br /&gt;   [self mySendData]; // start off by sending data upon connection&lt;br /&gt;   break;&lt;br /&gt;   &lt;br /&gt;  case GKPeerStateDisconnected:&lt;br /&gt;   break;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)peerPickerController:(GKPeerPickerController *)picker didConnectToPeer:(NSString *)peerID {&lt;br /&gt; printf("connection was successful! start the game.\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker {&lt;br /&gt; printf("connection attempt was canceled\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)mySendData {&lt;br /&gt; // allocate the NSData&lt;br /&gt; myNumber++;&lt;br /&gt; myData = [[NSData alloc] initWithBytes:&amp;myNumber length:sizeof(int)];&lt;br /&gt; [session sendDataToAllPeers :myData withDataMode:GKSendDataReliable error:nil];&lt;br /&gt; printf("send data: %i\n", myNumber);&lt;br /&gt; textView.text = [NSString stringWithFormat:@"myNumber: %i\n", myNumber];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context&lt;br /&gt;{&lt;br /&gt;    // Read the bytes in data and perform an application-specific action, then free the NSData object&lt;br /&gt; [data getBytes:&amp;myNumber length:sizeof(int)];&lt;br /&gt; printf("received data: %i from: %s\n", myNumber, [peer UTF8String]);&lt;br /&gt; textView.text = [NSString stringWithFormat:@"myNumber: %i\n", myNumber];&lt;br /&gt; &lt;br /&gt; [self mySendData];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)dealloc&lt;br /&gt;{&lt;br /&gt; [picker release];&lt;br /&gt; [session release];&lt;br /&gt; [textView release];&lt;br /&gt; [glView release];&lt;br /&gt;    [window release];&lt;br /&gt;    [super dealloc];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/dd&gt;&lt;/code&gt;&lt;/dl&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-8689459320462177534?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/8689459320462177534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=8689459320462177534' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8689459320462177534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8689459320462177534'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/03/sample-source-code-iphone-os-30-peer-to.html' title='Sample Source Code : iPhone OS 3.0 peer to peer bluetooth connectivity'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2788625621342973025</id><published>2009-03-23T20:11:00.028+08:00</published><updated>2009-04-13T19:08:04.086+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Push Notification Service'/><title type='text'>Apple Push Notification Service (APNS)</title><content type='html'>The Apple Push Notification Service will be launched in this summer and this is one of interesting features of iPhone OS 3.0.  &lt;br /&gt;&lt;br /&gt;Since the SSL certificate for the APNS for the developer's app is not yet available (update: available now on April 9) in the developer program portal, we need to simulate and test it in our environment at this moment.  To prepare for this, we need a client program and a server program (for testing with the client) implementing the TLS communication protocol.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;(1) Requirements&lt;/span&gt;&lt;br /&gt;The requirement of communication with Apple Push Notification Service (APNS) is described in the "Apple Push Notification Service Programming Guide" and for the developer's view, we need to have a client program to communicate with and send the payload to the APNS&lt;br /&gt;&lt;br /&gt;- a "raw" (binary) socket interface which is asynchronous and one-way from developer to APNS&lt;br /&gt;- The binary interface is available through gateway.push.apple.com, port 2195&lt;br /&gt;- use TLS (or SSL) to establish a secured communications channel&lt;br /&gt;- The SSL certificate (will be provided from Apple per Application ID from developer portal) is required for these connections&lt;br /&gt;- should present this certificate to APNS at connection time using peer-to-peer authentication. &lt;br /&gt;- should also retain connections with APNS across multiple notifications.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;(2) Payload&lt;/span&gt;&lt;br /&gt;The maximum size allowed for a notification payload is 256 bytes;&lt;br /&gt;Example of the notification payload&lt;br /&gt;&lt;br /&gt;Command : 1 byte (0x00)&lt;br /&gt;Device Token length : 2 bytes (0x00 0x20)&lt;br /&gt;Device Token(binary) : 32 bytes&lt;br /&gt;Payload length : 2 bytes&lt;br /&gt;Payload Content (max 256 bytes): e.g.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{&lt;br /&gt;"aps" : {&lt;br /&gt;  "alert" : {"loc-key":"%@ and %@ have invited you to Dinner","loc-args":["Jenna","Frank"]},&lt;br /&gt;  "badge" : 9&lt;br /&gt;  "sound" : "happysound.aiff"&lt;br /&gt; },&lt;br /&gt;"acme1" : "custom property",&lt;br /&gt;"acme2" : 42,&lt;br /&gt;"acme3" : [5,8]&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The following example shows the payload message of &lt;br /&gt;&lt;code&gt;{"aps":{"alert":"Message from javacom","badge":9}}&lt;/code&gt;&lt;br /&gt;in HexEdit Screen&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sd8aolAvudI/AAAAAAAAAtc/ZI_ZEBhYL1c/s1600-h/pushdata2.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 82px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/Sd8aolAvudI/AAAAAAAAAtc/ZI_ZEBhYL1c/s400/pushdata2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5323002569007544786" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;#define DEVICE_BINARY_SIZE 32&lt;br /&gt;#define MAXPAYLOAD_SIZE 256&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;(3) Pseudocode for this client side program (My iniitial draft for C Code)&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SeMc-hlCZjI/AAAAAAAAAuM/GeTLzPWA2b0/s1600-h/tls.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 270px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SeMc-hlCZjI/AAAAAAAAAuM/GeTLzPWA2b0/s400/tls.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5324131044973241906" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Client code for TLS v1 protocol&lt;br /&gt;Needs openssl crypto lib&lt;br /&gt;&lt;br /&gt;At first&lt;br /&gt;Initialisation of TLS Context and return SSL Context&lt;br /&gt;SSL_CTX *ctx;&lt;br /&gt;SSL *ssl;&lt;br /&gt;&lt;br /&gt;SSL_CTX object is created as a framework to establish TLS/SSL enabled connections &lt;br /&gt;  use SSL_CTX_new to create a new context&lt;br /&gt;SSL_CTX should include the tls stuff for SSL certificate handling&lt;br /&gt;  use SSL_CTX_set_client_cert_cb(ctx, client_cert_cb) to provide client SSL cert.&lt;br /&gt;&lt;br /&gt;socket is created for the APNS&lt;br /&gt;int sock;&lt;br /&gt;struct sockaddr_in server;&lt;br /&gt;&lt;br /&gt;connect socket &lt;br /&gt;   connect(sock, (struct sockaddr *)&amp;server, sizeof(server))&lt;br /&gt;&lt;br /&gt;Then associate the network connection with the object&lt;br /&gt;&lt;br /&gt;create a new SSL structure for a connection &lt;br /&gt;   SSL_new(ctx))) &lt;br /&gt;&lt;br /&gt;connect the SSL object with a socket file descriptor &lt;br /&gt;   SSL_set_app_data(ssl, conn);&lt;br /&gt;   SSL_set_fd(ssl, sock)&lt;br /&gt;&lt;br /&gt;Set ssl to work in client mode (that is to connect)&lt;br /&gt;  SSL_set_connect_state(ssl);&lt;br /&gt;&lt;br /&gt;Then the TLS/SSL handshake is performed&lt;br /&gt;Connect SSL&lt;br /&gt;   SSL_connect&lt;br /&gt;If connect successful&lt;br /&gt;  Compose Payload&lt;br /&gt;  sendPayload using SSL_write (this part was given by Apple)&lt;br /&gt;&lt;br /&gt;If connect unsuccessful, handle error&lt;br /&gt;&lt;br /&gt;If Payload sent or reach maximum retries&lt;br /&gt;Then Shut down the TLS/SSL connection.&lt;br /&gt;SSL_shutdown(ssl);&lt;br /&gt;SSL_free(ssl);&lt;br /&gt;Destroy SSL Context&lt;br /&gt;SSL_CTX_free(ctx); ctx = NULL&lt;br /&gt;close(sock);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SeGu7p2IzVI/AAAAAAAAAtk/MSQDj4NnV60/s1600-h/apns.c.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 279px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SeGu7p2IzVI/AAAAAAAAAtk/MSQDj4NnV60/s400/apns.c.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5323728574397074770" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;(4) Other aspects (TO-DOs)&lt;/span&gt;&lt;br /&gt;-  Keep the definitive count of data items remaining to be downloaded.&lt;br /&gt;-  Regularly connect with the feedback web server and fetch the current list of those devices that have repeatedly reported failed-delivery attempts.&lt;br /&gt;- iPhone client program&lt;br /&gt;&lt;br /&gt;see update here&lt;br /&gt;&lt;a href="http://iphonesdkdev.blogspot.com/2009/04/apns-client-development-certificate.html"&gt;http://iphonesdkdev.blogspot.com/2009/04/apns-client-development-certificate.html&lt;/a&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2788625621342973025?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2788625621342973025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2788625621342973025' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2788625621342973025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2788625621342973025'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/03/apple-push-notification-service-apns.html' title='Apple Push Notification Service (APNS)'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_3LRNVfBfliQ/Sd8aolAvudI/AAAAAAAAAtc/ZI_ZEBhYL1c/s72-c/pushdata2.png' height='72' width='72'/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-9058547468410174490</id><published>2009-03-20T23:15:00.008+08:00</published><updated>2009-03-22T02:43:25.138+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tethering'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone OS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='MMS'/><title type='text'>3G Tethering &amp; MMS for iPhone OS 3.0 beta</title><content type='html'>&lt;img src="http://www.iphone.org.hk/attach/51645-3gon-embed.PNG"/&gt;&lt;img src="http://www.iphone.org.hk/attach/51649-3gblue-embed.PNG"/&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/51655-mms-embed.PNG"/&gt;&lt;img src="http://www.iphone.org.hk/attach/51684-3hkmmsok-embed.png"/&gt;&lt;br /&gt;&lt;br /&gt;Use this shell command to find out the ipcc file for your country&lt;br /&gt;&lt;code&gt;curl -s -L http://phobos.apple.com/version | grep -i carrier&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then follow these instructions below to amend the bundle contents&lt;br /&gt;&lt;br /&gt;Instruction for 3G Tethering is here&lt;br /&gt;&lt;a href="http://www.iphonealley.com/news/hacker-enables-usb-tethering-in-30-beta"&gt;http://www.iphonealley.com/news/hacker-enables-usb-tethering-in-30-beta&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Instruction for MMS is here&lt;br /&gt;&lt;a href="http://forums.macrumors.com/showthread.php?t=671426"&gt;http://forums.macrumors.com/showthread.php?t=671426&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can also change the carrier logo, if you modified the png files in the bundle&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-9058547468410174490?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/9058547468410174490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=9058547468410174490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/9058547468410174490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/9058547468410174490'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/03/3g-tethering-for-iphone-os-30-beta.html' title='3G Tethering &amp; MMS for iPhone OS 3.0 beta'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7587457613456164523</id><published>2009-02-21T12:43:00.000+08:00</published><updated>2009-02-21T12:44:08.834+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Thank you'/><title type='text'>Thank you</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SZ-GCo7yjtI/AAAAAAAAArM/JaW1gC1Pypc/s1600-h/visits.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 377px; height: 400px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SZ-GCo7yjtI/AAAAAAAAArM/JaW1gC1Pypc/s400/visits.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5305106265971789522" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7587457613456164523?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7587457613456164523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7587457613456164523' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7587457613456164523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7587457613456164523'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/02/thank-you.html' title='Thank you'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_3LRNVfBfliQ/SZ-GCo7yjtI/AAAAAAAAArM/JaW1gC1Pypc/s72-c/visits.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3400653442457364744</id><published>2009-02-03T17:50:00.065+08:00</published><updated>2011-05-23T07:43:23.843+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Decrypted IPA'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='re-codesign'/><title type='text'>How to re-codesign iPhone binary ?</title><content type='html'>The codesign certificate from Apple is used by developers to compile the source code and deploy their iPhone Apps to device. &lt;br /&gt;&lt;br /&gt;Have you ever think of how to re-codesign an already compiled iPhone binary and deploy that app to non-jailbroken iPhone without the source code and without re-compiling in Xcode ?  That means only &lt;span style="font-weight:bold;"&gt;re-codesign the binary with the developer certificate again&lt;/span&gt; so that XCode can deploy it to development devices such as iPhone / iPod Touch.  By using this method, you can patch the existing binary / add localization bundles or change the graphic files before re-codesign and deployment to device.&lt;br /&gt;&lt;br /&gt;For example, there was a very nice app called NetShare which was pulled from the App Store, sometimes ago.&lt;br /&gt;&lt;br /&gt;Would it be nice, if I can re-codesign (using the developer certificate) the NetShare binary and deploy it to my iPhone 3G, no jailbreak required.  I can use it for tethering  in cellular wireless.&lt;br /&gt;&lt;br /&gt;I have done it, and the developer certificate is used to change the codesign signature and the app can be installed to non-jailbroken iPhone / iPod Touch successfully.  This requires a hack on the original ipa file downloaded from App Store.&lt;br /&gt;&lt;br /&gt;The following screen dump is captured from my iPod Touch second generation, no jailbreak.  (I did not use redsn0w)&lt;br /&gt;&lt;br /&gt;In my testing in iPhone 3G, Netshare can tether the 3G cellular networking using Mac OS X using the SOCKS Proxy.  Safari Web Browing, iChat and iTunes work.  But Microsoft Messenger and Mail do not work.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SYgW147kamI/AAAAAAAAAqg/QgCJheFHX9g/s1600-h/netshare.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 267px; height: 400px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SYgW147kamI/AAAAAAAAAqg/QgCJheFHX9g/s400/netshare.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5298510076672502370" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To implement the re-codesign, you first need a decrypted ipa, there are lots of them out there in the net.  Don't ask me to give you.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Part I Decrypted IPA&lt;/span&gt;&lt;/span&gt;&lt;div&gt;Please take note that you don't need this method to decrypt the IPA file, if you already have the decrypted one downloaded from the net (those ipa files floating in the net are already decrypted).&lt;br /&gt;&lt;br /&gt;If you have that particular app installed in iPhone from AppStore directly, it needs to be decrypted in order to be useful.  One of the decrypt methods is to use a jailbreak iPhone and run the script (source from pr0x.org Forum) below in iPhone to create the decrypted ipa.&lt;br /&gt;To use this method you must have installed the app from App Store in jailbreak iPhone plus the following packages from Cydia&lt;br /&gt;&lt;code&gt;apt-get install com.ericasadun.utilities gdb gawk zip ldid odcctools&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To find out the app names with descending date order that your iPhone have installed, run this command in iPhone&lt;br /&gt;&lt;code&gt;find /var/mobile/Applications/ -iname *.app  | xargs -0 ls -ldt&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and use this command to generated the decrypted ipa e.g. &lt;br /&gt;&lt;code&gt;./DCrypt.sh "Monkey Ball"&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;DCrypt.sh &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# DeCrypt - v1.1 (2008-10-21)&lt;br /&gt;#  - v1.1 (2008-10-21)&lt;br /&gt;# FloydianSlip&lt;br /&gt;#&lt;br /&gt;# Heavily based on xcrack&lt;br /&gt;#&lt;br /&gt;# Many thanks to:&lt;br /&gt;#    puy0, SaladFork, Flox, Flawless&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;echo "DeCrypt 1.1 (2008-10-21)"&lt;br /&gt;echo "FloydianSlip"&lt;br /&gt;echo&lt;br /&gt;&lt;br /&gt;if [ ! -e /usr/bin/plutil ]; then&lt;br /&gt;echo "Cannot find plutil (apt-get install com.ericasadun.utilities)"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -e /usr/bin/gdb ]; then&lt;br /&gt;echo "Cannot find gdb (apt-get install gdb)"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -e /usr/bin/otool ]; then&lt;br /&gt;echo "Cannot find otool (apt-get install odcctools)"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -e /usr/bin/ldid ]; then&lt;br /&gt;echo "Cannot find otool (apt-get install ldid)"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if [ ! -e /usr/bin/awk ]; then&lt;br /&gt;       echo "Cannot find awk (apt-get install gawk)"&lt;br /&gt;       exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -e /usr/bin/zip ]; then&lt;br /&gt;       echo "Cannot find zip (apt-get install zip)"&lt;br /&gt;       exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ $# -ne 1 ]; then&lt;br /&gt;echo "Usage: $(basename $0) &amp;lt;ApplicationName&amp;gt;"&lt;br /&gt;echo&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;AppInput=$1&lt;br /&gt;&lt;br /&gt;if [ -d "$AppInput" ]; then&lt;br /&gt;       tempLoc=$AppInput&lt;br /&gt;else&lt;br /&gt;echo "Locating $AppInput"&lt;br /&gt;tempLoc=$(find /var/mobile/Applications -iname "$AppInput.app")&lt;br /&gt;if [ -z "$tempLoc" ]; then&lt;br /&gt; echo "Unable to locate $AppInput"&lt;br /&gt; exit 1&lt;br /&gt;fi&lt;br /&gt;AppCount=$(find /var/mobile/Applications -iname "$AppInput.app" | wc -l)&lt;br /&gt;if [ $AppCount -gt 1 ]; then&lt;br /&gt; echo "Found two installation directories:"&lt;br /&gt; find /var/mobile/Applications -iname "$AppInput.app"&lt;br /&gt; exit 1&lt;br /&gt;fi&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;AppPath=$(dirname "$tempLoc")&lt;br /&gt;AppName=$(basename "$tempLoc")&lt;br /&gt;AppExec=$(plutil -v CFBundleExecutable "$tempLoc/Info.plist" 2&gt;&amp;amp;1 | awk -F "] " '{ print $2 }')&lt;br /&gt;AppVer=$(plutil -v CFBundleVersion "$tempLoc/Info.plist" 2&gt;&amp;amp;1 | awk -F "] " '{ print $2 }')&lt;br /&gt;AppDisplayName=$(plutil -v CFBundleDisplayName "$tempLoc/Info.plist" 2&gt;&amp;amp;1 | awk -F "] " '{ print $2 }')&lt;br /&gt;&lt;br /&gt;if [ ! -d "$AppPath" ]; then&lt;br /&gt;echo "Unable to locate original installation directory"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -d "$AppPath/$AppName" ]; then&lt;br /&gt;echo "Unable to locate .app directory"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -e "$AppPath/$AppName/$AppExec" ]; then&lt;br /&gt;echo "Unable to locate executable"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Found $AppName"&lt;br /&gt;&lt;br /&gt;echo "Creating directories"&lt;br /&gt;WorkDir="/tmp/DecryptApp-$(date +%Y%m%d-%H%M%S)"&lt;br /&gt;NewAppDir="$HOME/Documents/Decrypted"&lt;br /&gt;&lt;br /&gt;if [ -e "$WorkDir" ]; then&lt;br /&gt;rm -rf "$WorkDir"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;mkdir -p "$WorkDir"&lt;br /&gt;&lt;br /&gt;if [ ! -e "$NewAppDir" ]; then&lt;br /&gt;mkdir -p "$NewAppDir"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ ! -d "$WorkDir" -o ! -d "$NewAppDir" ]; then&lt;br /&gt;echo "Unable to create Directories"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Copying application files"&lt;br /&gt;&lt;br /&gt;cp -a "$AppPath/$AppName/" "$WorkDir/"&lt;br /&gt;&lt;br /&gt;if [ ! -e "$WorkDir/$AppName/$AppExec" ]; then&lt;br /&gt;echo "Unable to copy application files"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Analyzing application"&lt;br /&gt;&lt;br /&gt;CryptID=$(otool -l "$WorkDir/$AppName/$AppExec" | grep cryptid | awk '{print $2}')&lt;br /&gt;if [ $CryptID -ne "1" ]; then&lt;br /&gt;echo "Application is not encrypted"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;CryptSize=$(otool -l "$WorkDir/$AppName/$AppExec" | grep cryptsize | awk '{print $2}')&lt;br /&gt;if [ ! $CryptSize ]; then&lt;br /&gt;echo "Unable to find CryptSize"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;CryptOff=$(otool -l "$WorkDir/$AppName/$AppExec" | grep cryptoff | awk '{print $2}')&lt;br /&gt;if [ ! $CryptOff ]; then&lt;br /&gt;       echo "Unable to find CryptOff"&lt;br /&gt;       rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Locating and patching CryptID"&lt;br /&gt;&lt;br /&gt;# "/System/Library/Frameworks" in hex&lt;br /&gt;PathAsHex="2f53797374656d2f4c6962726172792f4672616d65776f726b73"&lt;br /&gt;&lt;br /&gt;# - Convert to hex on 1 long line, only take stuff before the path string,&lt;br /&gt;# - Convert to 1 byte set per line, find 0x01 (line number is offset in the real file),&lt;br /&gt;# - Strip newlines, reverse the order&lt;br /&gt;oneLocations=($(od -A n -t x1 -v "$WorkDir/$AppName/$AppExec" | \&lt;br /&gt;tr -d ' ','\n' | \&lt;br /&gt;sed "s/$PathAsHex.*\$//" | \&lt;br /&gt;sed "s/../&amp;amp;\n/g" | \&lt;br /&gt;grep -n -s 01 | \&lt;br /&gt;cut -d : -f 1 | \&lt;br /&gt;sort -nr | \&lt;br /&gt;tr "\n" " "))&lt;br /&gt;&lt;br /&gt;for TryOffset in "${oneLocations[@]}"; do&lt;br /&gt;cp -a "$WorkDir/$AppName/$AppExec" "$WorkDir/$AppName/$AppExec.trying"&lt;br /&gt;foo=$(echo -ne "\x00" | dd bs=1 seek=$((TryOffset - 1)) conv=notrunc status=noxfer of="$WorkDir/$AppName/$AppExec.trying" 2&gt;&amp;amp;1&gt; /dev/null)&lt;br /&gt;cid=$(otool -l "$WorkDir/$AppName/$AppExec.trying" | grep cryptid | awk '{print $2}')&lt;br /&gt;if [ $cid -eq 0 ]; then&lt;br /&gt; break&lt;br /&gt;fi&lt;br /&gt;rm "$WorkDir/$AppName/$AppExec.trying"&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;if [ ! -e "$WorkDir/$AppName/$AppExec.trying" ]; then&lt;br /&gt;echo "Unable to find CryptID"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;mv "$WorkDir/$AppName/$AppExec.trying" "$WorkDir/$AppName/$AppExec"&lt;br /&gt;&lt;br /&gt;echo "Dumping unencrypted data from application"&lt;br /&gt;&lt;br /&gt;echo -e "set sharedlibrary load-rules \".*\" \".*\" none\r\n\&lt;br /&gt;set inferior-auto-start-dyld off\r\n\&lt;br /&gt;set sharedlibrary preload-libraries off\r\n\&lt;br /&gt;set sharedlibrary load-dyld-symbols off\r\n\&lt;br /&gt;handle all nostop\r\n\&lt;br /&gt;break *0x2000\r\n&lt;br /&gt;commands 1\r\n\&lt;br /&gt;dump memory $WorkDir/dump.bin 0x2000 $(($CryptSize + 0x2000))\r\n\&lt;br /&gt;kill\r\n\&lt;br /&gt;quit\r\n\&lt;br /&gt;end\r\n\&lt;br /&gt;start" &gt; $WorkDir/batch.gdb&lt;br /&gt;&lt;br /&gt;foo=$(gdb -q -e "$AppPath/$AppName/$AppExec" -x $WorkDir/batch.gdb -batch 2&gt;&amp;amp;1&gt; /dev/null)&lt;br /&gt;&lt;br /&gt;rm $WorkDir/batch.gdb&lt;br /&gt;&lt;br /&gt;echo "Verifiying data dump"&lt;br /&gt;&lt;br /&gt;DumpSize=$(stat -c%s "$WorkDir/dump.bin")&lt;br /&gt;if [ "$DumpSize" != "$CryptSize" ]; then&lt;br /&gt;echo "Memory dump is not the right size or does not exist"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Replacing encrypted data with data dump"&lt;br /&gt;foo=$(dd seek=4096 bs=1 conv=notrunc if="$WorkDir/dump.bin" of="$WorkDir/$AppName/$AppExec" 2&gt;&amp;amp;1&gt; /dev/null)&lt;br /&gt;rm "$WorkDir/dump.bin"&lt;br /&gt;&lt;br /&gt;echo "Signing the application"&lt;br /&gt;foo=$(ldid -s "$WorkDir/$AppName/$AppExec" 2&gt;&amp;amp;1&gt; /dev/null)&lt;br /&gt;plutil -s 'SignerIdentity' -v 'Apple iPhone OS Application Signing' "$WorkDir/$AppName/Info.plist" 2&gt;&amp;amp;1&gt; /dev/null&lt;br /&gt;&lt;br /&gt;if [ -e "$WorkDir/$AppName/SC_Info" ]; then&lt;br /&gt;echo "Removing SC_Info"&lt;br /&gt;rm -fr "$WorkDir/$AppName/SC_Info"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ -e "$WorkDir/$AppName/_CodeSignature" ]; then&lt;br /&gt;echo "Removing _CodeSignature"&lt;br /&gt;rm -fr "$WorkDir/$AppName/_CodeSignature"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ -h "$WorkDir/$AppName/CodeResources" ]; then&lt;br /&gt;echo "Removing CodeResources"&lt;br /&gt;rm -fr "$WorkDir/$AppName/CodeResources"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ -e "$WorkDir/$AppName/ResourceRules.plist" ]; then&lt;br /&gt;echo "Removing ResourceRules.plist"&lt;br /&gt;rm -fr "$WorkDir/$AppName/ResourceRules.plist"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Building .ipa"&lt;br /&gt;&lt;br /&gt;mkdir -p "$WorkDir/Payload"&lt;br /&gt;if [ ! -e "$WorkDir/Payload" ]; then&lt;br /&gt;echo "Failed to create Payload directory"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;mv "$WorkDir/$AppName" "$WorkDir/Payload/"&lt;br /&gt;&lt;br /&gt;echo "Copying iTunesArtwork"&lt;br /&gt;&lt;br /&gt;if [ -e "$AppPath/iTunesArtwork" ]; then&lt;br /&gt;cp -a "$AppPath/iTunesArtwork" "$WorkDir/"&lt;br /&gt;else&lt;br /&gt;echo "Unable to find iTunesArtwork"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Compressing the .ipa"&lt;br /&gt;IPAName=$NewAppDir/$(echo $AppDisplayName | sed -e "s: :_:g")-v$AppVer.ipa&lt;br /&gt;cd "$WorkDir"&lt;br /&gt;zip -m -r "$IPAName" * 2&gt;&amp;amp;1&gt; /dev/null&lt;br /&gt;cd - 2&gt;&amp;amp;1&gt; /dev/null&lt;br /&gt;if [ ! -e "$IPAName" ]; then&lt;br /&gt;echo "Failed to compress the .ipa"&lt;br /&gt;rm -fr "$WorkDir"&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo "Removing temporary files"&lt;br /&gt;rm -rf "$WorkDir"&lt;br /&gt;&lt;br /&gt;echo "Done"&lt;br /&gt;echo "Created decrypted .ipa at $IPAName"&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Part II Installation of XCode Template&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -O http://apiexplorer.googlecode.com/files/CrappStore.zip&lt;br /&gt;unzip -o CrappStore.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application/"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Part III XCode Build &amp;amp; Go&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;To install the decrypted ipa to non-jailbreak iPhone via XCode, you need the followings and a fully functional build &amp;amp; go iPhone device with iPhone SDK development environment with all Official certificates and Provisioning Profiles from Apple installed in Mac and iPhone /iPod Touch device&lt;div&gt;1) The XCode Template called CrappStore (see installation instruction in Part II above)&lt;br /&gt;2) Official Developer Certificate from Apple installed in Mac&lt;br /&gt;3) Official Development Provisioning Profile from Apple installed in Mac and iPhone / iPod Touch for development&lt;br /&gt;4) XCode and iPhone SDK (I have tested it on iPhone SDK 2.2.1, but should work on earlier versions) installed in Mac (Intel)&lt;br /&gt;&lt;br /&gt;Steps to Build &amp;amp; Go in Mac Xcode&lt;br /&gt;1) Get the project name from the ipa file &lt;code&gt;unzip -l Monkey_Ball-v1.02.ipa&lt;/code&gt;&lt;br /&gt;2) Create a new project from the CrappStore XCode Template with Project Name same as the decrypted ipa e.g. "Monkey Ball"&lt;br /&gt;3) Copy the decrypted ipa file (with extension .ipa) to the newly created Project folder (only copy one .ipa file to that project folder)&lt;br /&gt;e.g. ~/Projects/Monkey\ Ball/Monkey_Ball-v1.02.ipa&lt;br /&gt;4) Make sure iPhone / iPod Touch is connected to USB and recognized by XCode&lt;br /&gt;5) Select &lt;span style="font-weight:bold;"&gt;Device&lt;/span&gt; - iPhone OS 2.0 (Project Settings)&lt;br /&gt;6) Click Build &amp;amp; Go to Device Release.  Or alternatively, you can simply build and then drag the product to the device's app list.&lt;br /&gt;Done&lt;br /&gt;&lt;br /&gt;It is possible to have other methods, but using the Xcode is the easiest one.  Moreover, you can patch / mod it before deployment to device.  If you have modified the app, remember to delete the ipa file in the project folder, so that it will not be unzipped again and overwrite your modding.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3400653442457364744?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3400653442457364744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3400653442457364744' title='20 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3400653442457364744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3400653442457364744'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/02/how-to-re-codesign-iphone-binary.html' title='How to re-codesign iPhone binary ?'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_3LRNVfBfliQ/SYgW147kamI/AAAAAAAAAqg/QgCJheFHX9g/s72-c/netshare.png' height='72' width='72'/><thr:total>20</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-8264044691605447565</id><published>2009-01-29T01:34:00.008+08:00</published><updated>2009-06-20T19:49:25.848+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Provisioning Profile'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><title type='text'>How to skip provisioning profile for iPhone SDK 2.2.1 (build 9M2621a)</title><content type='html'>The trick to skip provisioning profile for iPhone SDK 2.1.1 (build 9M2621a) still works&lt;br /&gt;&lt;br /&gt;Just backup and edit the file and add the magic words as shown below highlighted in red color&lt;br /&gt;&lt;br /&gt;/Developer/Platforms/iPhoneOS.platform/Info.plist&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Info.plist:&lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;key&amp;gt;OverrideProperties&amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;dict&amp;gt;&lt;br /&gt;  &amp;lt;key&amp;gt;CODE_SIGN_CONTEXT_CLASS&amp;lt;/key&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;XCiPhoneOSCodeSignContext&amp;lt;/string&amp;gt;&lt;br /&gt;  &amp;lt;key&amp;gt;DEBUG_INFORMATION_FORMAT&amp;lt;/key&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;dwarf-with-dsym&amp;lt;/string&amp;gt;&lt;br /&gt;  &amp;lt;key&amp;gt;EMBEDDED_PROFILE_NAME&amp;lt;/key&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;embedded.mobileprovision&amp;lt;/string&amp;gt;&lt;br /&gt;  &amp;lt;key&amp;gt;SDKROOT&amp;lt;/key&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;iphoneos2.2.1&amp;lt;/string&amp;gt;&lt;br /&gt;  &lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&amp;lt;key&amp;gt;PROVISIONING_PROFILE_ALLOWED&amp;lt;/key&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;NO&amp;lt;/string&amp;gt;&lt;br /&gt;  &amp;lt;key&amp;gt;PROVISIONING_PROFILE_REQUIRED&amp;lt;/key&amp;gt;&lt;br /&gt;  &amp;lt;string&amp;gt;NO&amp;lt;/string&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;lt;/dict&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;Please remember to restart your Xcode after the amendment above.&lt;br /&gt;&lt;br /&gt;For MobileInstallation patch, please use my package (updated to support firmware 2.2.1) as posted here&lt;br /&gt;&lt;a href="http://hackint0sh.org/forum/showpost.php?p=340693&amp;postcount=14"&gt;http://hackint0sh.org/forum/showpost.php?p=340693&amp;postcount=14&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Related articles from this blog&lt;br /&gt;&lt;a href="http://iphonesdkdev.blogspot.com/2008/11/how-to-skip-provisioning-profile-for.html"&gt;http://iphonesdkdev.blogspot.com/2008/11/how-to-skip-provisioning-profile-for.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://iphonesdkdev.blogspot.com/2008/09/xcode-template-for-pwned-iphone-device.html"&gt;http://iphonesdkdev.blogspot.com/2008/09/xcode-template-for-pwned-iphone-device.html&lt;/a&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-8264044691605447565?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/8264044691605447565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=8264044691605447565' title='20 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8264044691605447565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/8264044691605447565'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/how-to-skip-provisioning-profile-for.html' title='How to skip provisioning profile for iPhone SDK 2.2.1 (build 9M2621a)'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>20</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-1076589341714853503</id><published>2009-01-25T22:37:00.024+08:00</published><updated>2009-01-27T21:47:24.310+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Foundation Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective C 2.0'/><title type='text'>Objective C 2.0, Foundation Framework Quick Reference</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SXx5Z-e6GmI/AAAAAAAAAqE/pBmBXFxR_sg/s1600-h/objc_basic_type.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 500px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SXx5Z-e6GmI/AAAAAAAAAqE/pBmBXFxR_sg/s400/objc_basic_type.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5295240749057186402" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SXx-qt3XrOI/AAAAAAAAAqM/Jl08xKZ5CWA/s1600-h/objc_dynamic.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 450px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SXx-qt3XrOI/AAAAAAAAAqM/Jl08xKZ5CWA/s400/objc_dynamic.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5295246534212300002" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Data Type Conversion Rules&lt;br /&gt;The Objective-C compiler adheres to very strict rules when it comes to evaluating expressions that consist of different data types.&lt;br /&gt;&lt;br /&gt;The following summarizes the order in which conversions take place in the evaluation of two operands in an expression:&lt;br /&gt;&lt;br /&gt;1. If either operand is of type long double, the other is converted to long double, and that is the type of the result.&lt;br /&gt;&lt;br /&gt;2. If either operand is of type double, the other is converted to double, and that is the type of the result.&lt;br /&gt;&lt;br /&gt;3. If either operand is of type float, the other is converted to float, and that is the type of the result.&lt;br /&gt;&lt;br /&gt;4. If either operand is of type _Bool, char, short int, or bit field,[1] or of an enumerated data type, it is converted to int.&lt;br /&gt;&lt;br /&gt;5. If either operand is of type long long int, the other is converted to long long int, and that is the type of the result.&lt;br /&gt;&lt;br /&gt;6. If either operand is of type long int, the other is converted to long int, and that is the type of the result.&lt;br /&gt;&lt;br /&gt;7. If this step is reached, both operands are of type int, and that is the type of the result.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SXyLW2a4vII/AAAAAAAAAqU/rG0Ixn5fe6Y/s1600-h/nsnumber.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 450px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SXyLW2a4vII/AAAAAAAAAqU/rG0Ixn5fe6Y/s400/nsnumber.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5295260486562528386" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt;NSString&lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) stringWithContentsOfFile: path encoding: enc error: err &lt;/TD&gt;&lt;TD&gt;Creates a new string and sets it to the path contents of a file specified by path using character encoding enc, returning error in err if non-nil&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) stringWithContentsOfURL: url encoding: enc error: err &lt;/TD&gt;&lt;TD&gt;Creates a new string and sets it to the contents of url using character encoding enc, returning error in err if non-nil&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) string &lt;/TD&gt;&lt;TD&gt;Creates a new empty string&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) stringWithString: nsstring &lt;/TD&gt;&lt;TD&gt;Creates a new string, setting it to nsstring&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithString: nsstring &lt;/TD&gt;&lt;TD&gt;Sets a newly allocated string to nsstring&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithContentsOfFile: path encoding: enc error: err &lt;/TD&gt;&lt;TD&gt;Sets a string to the contents of a file specified by path&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithContentsOfURL: url encoding enc error: err &lt;/TD&gt;&lt;TD&gt;Sets a string to the contents of url (NSURL *) url using character encoding enc, returning error in err if non-nil&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSUInteger) length &lt;/TD&gt;&lt;TD&gt;Returns the number of characters in the string&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(unichar) characterAtIndex: i &lt;/TD&gt;&lt;TD&gt;Returns the Unicode character at index i&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) substringFromIndex: i &lt;/TD&gt;&lt;TD&gt;Returns a substring from the character at i to the end&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) substringWithRange: range &lt;/TD&gt;&lt;TD&gt;Returns a substring based on a specified range&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) substringToIndex: i &lt;/TD&gt;&lt;TD&gt;Returns a substring from the start of the string up to the character at index i&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSComparator *) caseInsensitiveCompare: nsstring &lt;/TD&gt;&lt;TD&gt;Compares two strings, ignoring case&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSComparator *) compare: nsstring &lt;/TD&gt;&lt;TD&gt;Compares two strings&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) hasPrefix: nsstring &lt;/TD&gt;&lt;TD&gt;Tests whether a string begins with nsstring&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) hasSuffix: nsstring &lt;/TD&gt;&lt;TD&gt;Tests whether a string ends with nsstring&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) isEqualToString: nsstring &lt;/TD&gt;&lt;TD&gt;Tests whether two strings are equal&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) capitalizedString &lt;/TD&gt;&lt;TD&gt;Returns a string with the first letter of every word capitalized (and the remaining letters in each word converted to lower case)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) lowercaseString &lt;/TD&gt;&lt;TD&gt;Returns a string converted to lower case&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) uppercaseString &lt;/TD&gt;&lt;TD&gt;Returns a string converted to upper case&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(const char *) UTF8String &lt;/TD&gt;&lt;TD&gt;Returns a string converted to a UTF-8 C-style character string&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(double) doubleValue &lt;/TD&gt;&lt;TD&gt;Returns a string converted to a double&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(float) floatValue &lt;/TD&gt;&lt;TD&gt;Returns a string converted to a floating value&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSInteger) integerValue &lt;/TD&gt;&lt;TD&gt;Returns a string converted to an NSInteger integer&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(int) intValue &lt;/TD&gt;&lt;TD&gt;Returns a string converted to an integer&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt;NSMutableString&lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) stringWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Creates a string initially containing size characters.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Initializes a string with an initial capacity of size characters.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) setString: nsstring &lt;/TD&gt;&lt;TD&gt;Sets a string to nsstring.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) appendString: nsstring &lt;/TD&gt;&lt;TD&gt;Appends nsstring to the end of the receiver.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) deleteCharactersInRange: range &lt;/TD&gt;&lt;TD&gt;Deletes characters in a specified range.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) insertString: nstring atIndex: i &lt;/TD&gt;&lt;TD&gt;Inserts nsstring into the receiver starting at index i.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) replaceCharactersInRange: range withString: nsstring &lt;/TD&gt;&lt;TD&gt;Replaces characters in a specified range with nsstring.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) replaceOccurrencesOf String: nsstring withString: nsstring2 options: opts range: range &lt;/TD&gt;&lt;TD&gt;Replaces all occurrences of nsstring with nsstring2 within a specified range and according to options opts. Options can include a bitwise-ORed combination of NSBackwardsSearch (the search starts from the end of range), NSAnchoredSearch (nsstring must match from the beginning of the range only), NSLiteralSearch (performs a byte-by-byte comparison), and NSCaseInsensitiveSearch.&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt;NSArray&lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) arrayWithObjects: obj1, obj2, ... nil &lt;/TD&gt;&lt;TD&gt;Creates a new array with obj1, obj2, ... as its elements&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) containsObject: obj &lt;/TD&gt;&lt;TD&gt;Determines whether the array contains obj (uses the isEqual: method)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSUInteger) count &lt;/TD&gt;&lt;TD&gt;Indicates the number of elements in the array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSUInteger) indexOfObject: obj &lt;/TD&gt;&lt;TD&gt;Specifies the index number of the first element that contains obj (uses the isEqual: method)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) objectAtIndex: i &lt;/TD&gt;&lt;TD&gt;Indicates the object stored in element i&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) makeObjectsPerform Selector: (SEL) selector &lt;/TD&gt;&lt;TD&gt;Sends the message indicated by selector to every element of the array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSArray *) sortedArrayUsing Selector: (SEL) selector &lt;/TD&gt;&lt;TD&gt;Sorts the array according to the comparison method specified by selector&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) writeToFile: path automically: (BOOL) flag &lt;/TD&gt;&lt;TD&gt;Writes the array to the specified file, creating a temporary file first if flag is YES&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; NSMutableArray &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) array &lt;/TD&gt;&lt;TD&gt;Creates an empty array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) arrayWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Creates an array with a specified initial size&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Initializes a newly allocated array with a specified initial size&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) addObject: obj &lt;/TD&gt;&lt;TD&gt;Adds obj to the end of the array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) insertObject: obj atIndex: i &lt;/TD&gt;&lt;TD&gt;Inserts obj into element i of the array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) replaceObjectAtIndex: i withObject: obj &lt;/TD&gt;&lt;TD&gt;Replaces element i of the array with obj&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) removeObject: obj &lt;/TD&gt;&lt;TD&gt;Removes all occurrences of obj from the array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) removeObjectAtIndex: i &lt;/TD&gt;&lt;TD&gt;Removes element i from the array, moving down elements i+1 through the end of the array&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) sortUsingSelector: (SEL) selector &lt;/TD&gt;&lt;TD&gt;Sorts the array based on the comparison method indicated by selector&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; NSDictionary &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) dictionaryWithObjectsAndKeys: obj1, key1, obj2, key2, ..., nil &lt;/TD&gt;&lt;TD&gt;Creates a dictionary with key-object pairs {key1, obj1}, {key2, obj2}, ...&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithObjectsAndKeys: obj1, key1, obj2, key2,..., nil &lt;/TD&gt;&lt;TD&gt;Initializes a newly allocated dictionary with key-object pairs {key1, obj1}, {key2, obj2}, ...&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(unsigned int) count &lt;/TD&gt;&lt;TD&gt;Returns the number of entries in the dictionary&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSEnumerator *) keyEnumerator &lt;/TD&gt;&lt;TD&gt;Returns an NSEnumerator object for all the keys in the dictionary&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSArray *) keysSortedByValueUsingSelector: (SEL) selector &lt;/TD&gt;&lt;TD&gt;Returns an array of keys in the dictionary sorted according to the comparison method selector specifies&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSEnumerator *) objectEnumerator &lt;/TD&gt;&lt;TD&gt;Returns an NSEnumerator object for all the values in the dictionary&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) objectForKey: key &lt;/TD&gt;&lt;TD&gt;Returns the object for the specified key&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; NSMutableDictionary &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) dictionaryWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Creates a mutable dictionary with an initial specified size&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Initializes a newly allocated dictionary to be of an initial specified size&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) removeAllObjects &lt;/TD&gt;&lt;TD&gt;Removes all entries from the dictionary&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) removeObjectForKey: key &lt;/TD&gt;&lt;TD&gt;Removes the entry for the specified key from the dictionary&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) setObject: obj forKey: key &lt;/TD&gt;&lt;TD&gt;Adds obj to the dictionary for the key key and replaces the value if key already exists&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; NSSet &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(id) setWithObjects: obj1, obj2, ..., nil &lt;/TD&gt;&lt;TD&gt;Creates a new set from the list of objects&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithObjects: obj1, obj2, ..., nil &lt;/TD&gt;&lt;TD&gt;Initializes a newly allocated set with a list of objects&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSUInteger) count &lt;/TD&gt;&lt;TD&gt;Returns the number of members in the set&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) containsObject: obj &lt;/TD&gt;&lt;TD&gt;Determines whether the set contains obj&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) member: obj &lt;/TD&gt;&lt;TD&gt;Determines whether the set contains obj (using the isEqual: method)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSEnumerator *) objectEnumerator &lt;/TD&gt;&lt;TD&gt;Returns an NSEnumerator object for all the objects in the set&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) isSubsetOfSet: nsset &lt;/TD&gt;&lt;TD&gt;Determines whether every member of the receiver is present in nsset&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) intersectsSet: nsset &lt;/TD&gt;&lt;TD&gt;Determines whether at least one member of the receiver appears in nsset&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) isEqualToSet: nsset &lt;/TD&gt;&lt;TD&gt;Determines whether the two sets are equal&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; NSMutableSet &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) setWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Creates a new set with an initial capacity to store size members&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(id) initWithCapacity: size &lt;/TD&gt;&lt;TD&gt;Sets the initial capacity of a newly allocated set to size members&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) addObject: obj &lt;/TD&gt;&lt;TD&gt;Adds obj to the set&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) removeObject: obj &lt;/TD&gt;&lt;TD&gt;Removes obj from the set&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) removeAllObjects &lt;/TD&gt;&lt;TD&gt;Removes all members of the receiver&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) unionSet: nsset &lt;/TD&gt;&lt;TD&gt;Adds each member of nsset to the receiver&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) minusSet: nsset &lt;/TD&gt;&lt;TD&gt;Removes all members of nsset from the receiver&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(void) intersectSet: nsset &lt;/TD&gt;&lt;TD&gt;Removes all members from the receiver that are not also in nsset&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; NSFileManager &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSData *) contentsAtPath: path &lt;/TD&gt;&lt;TD&gt;Reads data from a file&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSData *) createFileAtPath: path contents: (NSData *) data attributes: attr &lt;/TD&gt;&lt;TD&gt;Writes data to a file&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) removeFileAtPath: path handler: handler &lt;/TD&gt;&lt;TD&gt;Removes a file&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) movePath: from toPath: to handler: handler &lt;/TD&gt;&lt;TD&gt;Renames or moves a file (to cannot already exist)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) copyPath: from toPath: to handler: handler &lt;/TD&gt;&lt;TD&gt;Copies a file (to cannot already exist)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) contentsEqualAtPath: path1 andPath: path2 &lt;/TD&gt;&lt;TD&gt;Compares contents of two files&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) fileExistsAtPath: path &lt;/TD&gt;&lt;TD&gt;Tests for file existence&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) isReadableFileAtPath: path &lt;/TD&gt;&lt;TD&gt;Tests whether file exists and can be read&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) isWritableFileAtPath: path &lt;/TD&gt;&lt;TD&gt;Tests whether file exists and can be written&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSDictionary *) fileAttributesAtPath: path traverseLink: (BOOL) flag &lt;/TD&gt;&lt;TD&gt;Gets attributes for file&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(BOOL) changeFileAttributes: attr atPath: path &lt;/TD&gt;&lt;TD&gt;Changes file attributes&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;TABLE border=1 width=70%&gt;&lt;tr&gt;&lt;td colspan=2&gt;Common &lt;b&gt; Path Utility &lt;/b&gt; Methods&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD&gt;Method&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;+(NSString *) pathWithComponents: components &lt;/TD&gt;&lt;TD&gt;Constructs a valid path from elements in components&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSArray *) pathComponents &lt;/TD&gt;&lt;TD&gt;Deconstructs a path into its constituent components&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) lastPathComponent &lt;/TD&gt;&lt;TD&gt;Extracts the last component in a path&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) pathExtension &lt;/TD&gt;&lt;TD&gt;Extracts the extension from the last component in a path&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByAppendingPathComponent: path &lt;/TD&gt;&lt;TD&gt;Adds path to the end of an existing path&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByAppendingPathExtension: ext &lt;/TD&gt;&lt;TD&gt;Adds the specified extension to the last component in the path&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByDeletingLastPathComponent &lt;/TD&gt;&lt;TD&gt;Removes the last path component&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByDeletingPathExtension &lt;/TD&gt;&lt;TD&gt;Removes the extension from the last path component&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByExpandingTildeInPath &lt;/TD&gt;&lt;TD&gt;Expands any tildes in the path to the user's home directory (~) or a specified user's home directory (~user)&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByResolvingSymlinksInPath &lt;/TD&gt;&lt;TD&gt;Attempts to resolve symbolic links in the path&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;TR&gt;&lt;TD&gt;-(NSString *) stringByStandardizingPath &lt;/TD&gt;&lt;TD&gt;Standardizes a path by attempting to resolve ~, ..(parent directory), .(current directory), and symbolic links&lt;/TD&gt;&lt;/TR&gt;&lt;br /&gt;&lt;/TABLE&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Common Resources Path for iPhone&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;NSBundle  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;NSString *myinfoplist = [ [ NSString alloc ] initWithFormat: @"%@/Info.plist", [[NSBundle mainBundle] resourcePath] ];&lt;br /&gt;NSLog (@"Documents Folder is %@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]);&lt;br /&gt;NSString *myFile = [ [ NSString alloc ] initWithFormat: @"%@/Documents/file.db", NSHomeDirectory() ];&lt;br /&gt; &lt;br /&gt;NSDirectoryEnumerator *dirEnum;&lt;br /&gt;NSString *file;&lt;br /&gt;dirEnum = [ [ NSFileManager defaultManager ] enumeratorAtPath:NSHomeDirectory()];&lt;br /&gt;while (file = [ dirEnum nextObject ]) {&lt;br /&gt; NSLog(@"%@",[NSHomeDirectory() stringByAppendingPathComponent:file]);&lt;br /&gt; /*&lt;br /&gt;  Documents/&lt;br /&gt;  Library/&lt;br /&gt;  Preferences/&lt;br /&gt;  MyApp.app/&lt;br /&gt;  */&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-1076589341714853503?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/1076589341714853503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=1076589341714853503' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1076589341714853503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/1076589341714853503'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/objective-c-20-quick-reference.html' title='Objective C 2.0, Foundation Framework Quick Reference'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_3LRNVfBfliQ/SXx5Z-e6GmI/AAAAAAAAAqE/pBmBXFxR_sg/s72-c/objc_basic_type.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7464608731118494566</id><published>2009-01-25T02:12:00.017+08:00</published><updated>2010-06-07T02:04:09.231+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><category scheme='http://www.blogger.com/atom/ns#' term='UIKit'/><category scheme='http://www.blogger.com/atom/ns#' term='Settings'/><title type='text'>iPhone Sample Source Code : UISlider UITextField UISwitch &amp; UISegmentedControl</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3LRNVfBfliQ/SXtbnPIQRdI/AAAAAAAAAp8/1nhTh9dGxVw/s1600-h/settings.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 300px;" src="http://2.bp.blogspot.com/_3LRNVfBfliQ/SXtbnPIQRdI/AAAAAAAAAp8/1nhTh9dGxVw/s400/settings.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5294926516538328530" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is a sample source code (no interface builder file)  implementing the one similar to Setting Bundle for UIKit Controls  &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;UISlider, UITextField, UISwitch &amp; UISegmentedControl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;main.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  main.m&lt;br /&gt;//  Settings&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt;    &lt;br /&gt;    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;    int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");&lt;br /&gt;    [pool release];&lt;br /&gt;    return retVal;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;AppDelegate.h &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  AppDelegate.h&lt;br /&gt;//  Settings&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;#pragma mark -&lt;br /&gt;#pragma mark MainViewController&lt;br /&gt;#pragma mark -&lt;br /&gt;&lt;br /&gt;@interface MainViewController : UITableViewController &amp;lt;UITextFieldDelegate&amp;gt;{&lt;br /&gt; &lt;br /&gt;    UITextField *activeTextField;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (id) init;&lt;br /&gt;- (void) dealloc;&lt;br /&gt;- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;&lt;br /&gt;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;&lt;br /&gt;- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;&lt;br /&gt;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;#pragma mark -&lt;br /&gt;#pragma mark AppDelegate&lt;br /&gt;#pragma mark -&lt;br /&gt;&lt;br /&gt;@interface AppDelegate : NSObject &amp;lt;UIApplicationDelegate&amp;gt; {&lt;br /&gt;    UIWindow *window;&lt;br /&gt;    MainViewController *viewController;&lt;br /&gt;    UINavigationController *navigationController;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) UIWindow *window;&lt;br /&gt;@property (nonatomic, retain) MainViewController *viewController;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;AppDelegate.m &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;//  AppDelegate.m&lt;br /&gt;//  Settings&lt;br /&gt;//&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#define DEBUG_BUILD&lt;br /&gt;&lt;br /&gt;#ifdef DEBUG_BUILD&lt;br /&gt;    #define DEBUGLOG(x) x&lt;br /&gt;    #define LogMethod() NSLog(@"%@ %@", self, NSStringFromSelector(_cmd))&lt;br /&gt;#else&lt;br /&gt;    #define DEBUGLOG(x)&lt;br /&gt;    #define LogMethod() &lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;#import "AppDelegate.h"&lt;br /&gt;&lt;br /&gt;#pragma mark -&lt;br /&gt;#pragma mark MainViewController&lt;br /&gt;#pragma mark -&lt;br /&gt;&lt;br /&gt;@implementation MainViewController&lt;br /&gt;&lt;br /&gt;- (id) init {&lt;br /&gt;    self = [ super initWithStyle: UITableViewStyleGrouped ];&lt;br /&gt; &lt;br /&gt;    if (self != nil) {&lt;br /&gt;        self.title = @"Settings";&lt;br /&gt;    }&lt;br /&gt;    return self;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void) loadView {&lt;br /&gt;    LogMethod();&lt;br /&gt;    [ super loadView ];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation&lt;br /&gt;{&lt;br /&gt;    LogMethod();&lt;br /&gt;    return (interfaceOrientation == UIInterfaceOrientationPortrait);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)didReceiveMemoryWarning {&lt;br /&gt;     LogMethod();&lt;br /&gt;    [ super didReceiveMemoryWarning ];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)dealloc {&lt;br /&gt;//    [ shipStabilityControl release ];&lt;br /&gt;    [ super dealloc ];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#pragma mark - UITableView delegates&lt;br /&gt;&lt;br /&gt;- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {&lt;br /&gt;    return 3;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section&lt;br /&gt;{&lt;br /&gt;    switch (section) {&lt;br /&gt;        case(0):&lt;br /&gt;            return 4;&lt;br /&gt;            break;&lt;br /&gt;        case(1):&lt;br /&gt;            return 3;&lt;br /&gt;            break;&lt;br /&gt;        case(2):&lt;br /&gt;            return 1;&lt;br /&gt;            break;&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section&lt;br /&gt;{&lt;br /&gt;    switch (section) {&lt;br /&gt;        case(0):&lt;br /&gt;            return @"Game Settings";&lt;br /&gt;            break;&lt;br /&gt;        case(1):&lt;br /&gt;            return @"Advanced Settings";&lt;br /&gt;            break;&lt;br /&gt;        case(2):&lt;br /&gt;            return @"About";&lt;br /&gt;            break;&lt;br /&gt;    }&lt;br /&gt;    return nil;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath&lt;br /&gt;{&lt;br /&gt;    NSString *CellIdentifier = [ NSString stringWithFormat: @"%d:%d", [ indexPath indexAtPosition: 0 ], [ indexPath indexAtPosition:1 ]];&lt;br /&gt; &lt;br /&gt;    UITableViewCell *cell = [ tableView dequeueReusableCellWithIdentifier: CellIdentifier];&lt;br /&gt; &lt;br /&gt;    if (cell == nil) {&lt;br /&gt;        cell = [ [ [ UITableViewCell alloc ] initWithFrame: CGRectZero reuseIdentifier: CellIdentifier] autorelease ];&lt;br /&gt;  &lt;br /&gt;        cell.selectionStyle = UITableViewCellSelectionStyleNone;&lt;br /&gt;  &lt;br /&gt;        switch ([ indexPath indexAtPosition: 0]) {&lt;br /&gt;            case(0):&lt;br /&gt;                switch([ indexPath indexAtPosition: 1]) {&lt;br /&gt;                    case(0):&lt;br /&gt;      {&lt;br /&gt;       UISlider *musicVolumeControl = [ [ UISlider alloc ] initWithFrame: CGRectMake(170, 0, 125, 50) ];&lt;br /&gt;       musicVolumeControl.minimumValue = 0.0;&lt;br /&gt;       musicVolumeControl.maximumValue = 10.0;&lt;br /&gt;       musicVolumeControl.tag = 0;&lt;br /&gt;       musicVolumeControl.value = 3.5;&lt;br /&gt;       musicVolumeControl.continuous = YES;&lt;br /&gt;       [musicVolumeControl addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];&lt;br /&gt;       [ cell addSubview: musicVolumeControl ];&lt;br /&gt;       cell.textLabel.text = @"Music Volume"; // OS3&lt;br /&gt;//       cell.text = @"Music Volume";&lt;br /&gt;       [ musicVolumeControl release ];&lt;br /&gt;      }&lt;br /&gt;                        break;&lt;br /&gt;                    case(1):&lt;br /&gt;      {&lt;br /&gt;       UISlider *gameVolumeControl = [ [ UISlider alloc ] initWithFrame: CGRectMake(170, 0, 125, 50) ];&lt;br /&gt;       gameVolumeControl.minimumValue = 0.0;&lt;br /&gt;       gameVolumeControl.maximumValue = 10.0;&lt;br /&gt;       gameVolumeControl.tag = 1;&lt;br /&gt;       gameVolumeControl.value = 3.5;&lt;br /&gt;       gameVolumeControl.continuous = YES;&lt;br /&gt;       [gameVolumeControl addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];&lt;br /&gt;       [ cell addSubview: gameVolumeControl ];&lt;br /&gt;       cell.textLabel.text = @"Game Volume"; // OS3&lt;br /&gt;//       cell.text = @"Game Volume";&lt;br /&gt;       [ gameVolumeControl release ];&lt;br /&gt;      }&lt;br /&gt;                        break;&lt;br /&gt;                    case(2):&lt;br /&gt;      {&lt;br /&gt;       UISegmentedControl *difficultyControl = [ [ UISegmentedControl alloc ] initWithFrame: CGRectMake(170, 5, 125, 35) ];&lt;br /&gt;       [ difficultyControl insertSegmentWithTitle: @"Easy" atIndex: 0 animated: NO ];&lt;br /&gt;       [ difficultyControl insertSegmentWithTitle: @"Hard" atIndex: 1 animated: NO ];&lt;br /&gt;       difficultyControl.selectedSegmentIndex = 0;&lt;br /&gt;       difficultyControl.tag = 2;&lt;br /&gt;       [difficultyControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];&lt;br /&gt;       [ cell addSubview: difficultyControl ];&lt;br /&gt;       cell.textLabel.text = @"Difficulty"; // OS3&lt;br /&gt;//       cell.text = @"Difficulty";&lt;br /&gt;       [difficultyControl release];&lt;br /&gt;      }&lt;br /&gt;                        break;&lt;br /&gt;     case(3):&lt;br /&gt;      {&lt;br /&gt;       UISegmentedControl *actionControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects: @"Check", @"Search", @"Tools", nil]];&lt;br /&gt;       actionControl.frame =  CGRectMake(145, 5, 150, 35);&lt;br /&gt;       actionControl.selectedSegmentIndex = 1;&lt;br /&gt;       actionControl.tag = 3;&lt;br /&gt;       [actionControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];&lt;br /&gt;       actionControl.segmentedControlStyle = UISegmentedControlStyleBar;&lt;br /&gt;      &lt;br /&gt;       [cell addSubview:actionControl];&lt;br /&gt;       cell.textLabel.text = @"Actions"; // OS3&lt;br /&gt;//       cell.text = @"Actions";&lt;br /&gt;       [actionControl release];&lt;br /&gt;      }&lt;br /&gt;                        break;&lt;br /&gt;                }&lt;br /&gt;                break;&lt;br /&gt;            case(1):&lt;br /&gt;                switch ([ indexPath indexAtPosition: 1 ]) {&lt;br /&gt;                    case(0):&lt;br /&gt;      {&lt;br /&gt;       UITextField *playerTextField = [ [ UITextField alloc ] initWithFrame: CGRectMake(150, 10, 145, 34) ];&lt;br /&gt;       playerTextField.adjustsFontSizeToFitWidth = YES;&lt;br /&gt;       playerTextField.textColor = [UIColor blackColor];&lt;br /&gt;       playerTextField.font = [UIFont systemFontOfSize:17.0];&lt;br /&gt;       playerTextField.placeholder = @"&lt;enter name&gt;";&lt;br /&gt;       playerTextField.backgroundColor = [UIColor clearColor];&lt;br /&gt;       playerTextField.autocorrectionType = UITextAutocorrectionTypeNo;        // no auto correction support&lt;br /&gt;       playerTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support&lt;br /&gt;       playerTextField.textAlignment = UITextAlignmentRight;&lt;br /&gt;       playerTextField.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)&lt;br /&gt;       playerTextField.returnKeyType = UIReturnKeyDone;&lt;br /&gt;       playerTextField.tag = 0;&lt;br /&gt;       playerTextField.delegate = self;&lt;br /&gt;       &lt;br /&gt;       playerTextField.clearButtonMode = UITextFieldViewModeNever; // no clear 'x' button to the right&lt;br /&gt;       playerTextField.text = @"";&lt;br /&gt;       [ playerTextField setEnabled: YES ];&lt;br /&gt;       [ cell addSubview: playerTextField ];&lt;br /&gt;       cell.textLabel.text = @"Player"; // OS3&lt;br /&gt;//       cell.text = @"Player";&lt;br /&gt;       [playerTextField release];&lt;br /&gt;      }&lt;br /&gt;                        break;&lt;br /&gt;                    case(1):&lt;br /&gt;      {&lt;br /&gt;       UISwitch *resetControl = [ [ UISwitch alloc ] initWithFrame: CGRectMake(200, 10, 0, 0) ];&lt;br /&gt;       resetControl.on = YES;&lt;br /&gt;       resetControl.tag = 1;&lt;br /&gt;       [resetControl addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];&lt;br /&gt;       [ cell addSubview: resetControl ];&lt;br /&gt;       cell.textLabel.text = @"Reset"; // OS3&lt;br /&gt;//       cell.text = @"Reset";&lt;br /&gt;       [resetControl release];&lt;br /&gt;      }&lt;br /&gt;      break;&lt;br /&gt;                    case(2):&lt;br /&gt;      {&lt;br /&gt;       UISwitch *debugControl = [ [ UISwitch alloc ] initWithFrame: CGRectMake(200, 10, 0, 0) ];&lt;br /&gt;       debugControl.on = NO;&lt;br /&gt;       debugControl.tag = 2;&lt;br /&gt;       [debugControl addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];&lt;br /&gt;       [ cell addSubview: debugControl ];&lt;br /&gt;       cell.textLabel.text = @"Debug"; // OS3&lt;br /&gt;//       cell.text = @"Debug";&lt;br /&gt;       [debugControl release];&lt;br /&gt;      }&lt;br /&gt;      break;&lt;br /&gt;    }&lt;br /&gt;                break;&lt;br /&gt;            case(2):&lt;br /&gt;    {&lt;br /&gt;     UITextField *versionControl = [ [ UITextField alloc ] initWithFrame: CGRectMake(170, 10, 125, 38) ];&lt;br /&gt;     versionControl.text = @"1.0.0 Rev. B";&lt;br /&gt;     [ cell addSubview: versionControl ];&lt;br /&gt;&lt;br /&gt;     [ versionControl setEnabled: YES ];&lt;br /&gt;     versionControl.tag = 2;&lt;br /&gt;     versionControl.delegate = self;&lt;br /&gt;     cell.textLabel.text = @"Version"; // OS3&lt;br /&gt;//     cell.text = @"Version";&lt;br /&gt;     [versionControl release];&lt;br /&gt;    }&lt;br /&gt;                break;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt;    return cell;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#pragma mark ControlEventTarget Actions&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)segmentAction:(UISegmentedControl*)sender&lt;br /&gt;{&lt;br /&gt; if ([activeTextField canResignFirstResponder])&lt;br /&gt;  [activeTextField resignFirstResponder];&lt;br /&gt; &lt;br /&gt; DEBUGLOG(NSLog(@"segmentAction: sender = %d, segment = %d",  [sender tag], [sender selectedSegmentIndex]));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)sliderAction:(UISlider*)sender&lt;br /&gt;{&lt;br /&gt; if ([activeTextField canResignFirstResponder])&lt;br /&gt;  [activeTextField resignFirstResponder];&lt;br /&gt; DEBUGLOG(NSLog(@"sliderAction: sender = %d, value = %.1f",  [sender tag], [sender value]));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)switchAction:(UISwitch*)sender&lt;br /&gt;{&lt;br /&gt; if ([activeTextField canResignFirstResponder])&lt;br /&gt;  [activeTextField resignFirstResponder];&lt;br /&gt; DEBUGLOG(NSLog(@"switchAction: sender = %d, isOn %d",  [sender tag], [sender isOn]));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#pragma mark &amp;lt;UITextFieldDelegate&amp;gt; Methods&lt;br /&gt;&lt;br /&gt;- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField&lt;br /&gt;{&lt;br /&gt; activeTextField = textField;&lt;br /&gt; DEBUGLOG(NSLog(@"textFieldShouldBeginEditing: sender = %d, %@",  [textField tag], [textField text]));&lt;br /&gt;    return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)textFieldDidEndEditing:(UITextField *)textField&lt;br /&gt;{&lt;br /&gt; DEBUGLOG(NSLog(@"textFieldDidEndEditing: sender = %d, %@",  [textField tag], [textField text]));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (BOOL)textFieldShouldReturn:(UITextField *)textField&lt;br /&gt;{&lt;br /&gt; DEBUGLOG(NSLog(@"textFieldShouldReturn: sender = %d, %@",  [textField tag], [textField text]));&lt;br /&gt; activeTextField = nil;&lt;br /&gt;    [textField resignFirstResponder];&lt;br /&gt;    return YES;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;#pragma mark -&lt;br /&gt;#pragma mark AppDelegate&lt;br /&gt;#pragma mark -&lt;br /&gt;&lt;br /&gt;@implementation AppDelegate&lt;br /&gt;&lt;br /&gt;@synthesize window;&lt;br /&gt;@synthesize viewController;&lt;br /&gt;&lt;br /&gt;- (void)applicationDidFinishLaunching:(UIApplication *)application &lt;br /&gt;{    &lt;br /&gt;    LogMethod();&lt;br /&gt;&lt;br /&gt;    // If you want the status bar to be hidden at launch use this:&lt;br /&gt;    //  application.statusBarHidden = YES;&lt;br /&gt;    //&lt;br /&gt;    // To set the status bar as black, use the following:&lt;br /&gt;    // application.statusBarStyle = UIStatusBarStyleBlackOpaque;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    // Create window&lt;br /&gt;    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];&lt;br /&gt;    &lt;br /&gt;    // this helps in debugging, so that you know "exactly" where your views are placed;&lt;br /&gt;    // if you see "red", you are looking at the bare window, otherwise use black&lt;br /&gt;    // window.backgroundColor = [UIColor redColor];&lt;br /&gt;&lt;br /&gt;    viewController = [ [ MainViewController alloc ] init ];&lt;br /&gt;&lt;br /&gt; navigationController = [ [ UINavigationController alloc ] initWithRootViewController: viewController ];&lt;br /&gt; &lt;br /&gt;    /* Anchor the view to the window */&lt;br /&gt;    [window addSubview:[navigationController view]];&lt;br /&gt;&lt;br /&gt;    /* Make the window key and visible */&lt;br /&gt;    [window makeKeyAndVisible];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application&lt;br /&gt;{&lt;br /&gt; // low on memory: do whatever you can to reduce your memory foot print here&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (void)dealloc&lt;br /&gt;{&lt;br /&gt;    [viewController release];&lt;br /&gt;    [navigationController release];&lt;br /&gt;    [window release];&lt;br /&gt;    [super dealloc];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7464608731118494566?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7464608731118494566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7464608731118494566' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7464608731118494566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7464608731118494566'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/iphone-sample-source-code-uislider.html' title='iPhone Sample Source Code : UISlider UITextField UISwitch &amp; UISegmentedControl'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_3LRNVfBfliQ/SXtbnPIQRdI/AAAAAAAAAp8/1nhTh9dGxVw/s72-c/settings.png' height='72' width='72'/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2377894868937733044</id><published>2009-01-21T17:32:00.022+08:00</published><updated>2009-04-17T12:56:36.106+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='hardware info'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>Source Code : Get Hardware Info of iPhone</title><content type='html'>This is a collection of open source codes to print out the hardware info of iPhone.  If you know more, please post link here in comment and I will update it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Battery Info&lt;/span&gt; source (requires IOKit header files from SimulatorSDK)&lt;br /&gt;http://forums.macrumors.com/showthread.php?t=474628&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Memory &amp; CPU&lt;/span&gt;&lt;br /&gt;http://furbo.org/2007/08/21/what-the-iphone-specs-dont-tell-you/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Process&lt;/span&gt;&lt;br /&gt;Landon Fuller, iphonesdk@googlegroups.com&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;hwinfo.c  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#import &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#import &amp;lt;string.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#import &amp;lt;mach/mach_host.h&amp;gt;&lt;br /&gt;#import &amp;lt;sys/sysctl.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;CoreFoundation/CoreFoundation.h&amp;gt;&lt;br /&gt;#include &amp;lt;IOKit/ps/IOPowerSources.h&amp;gt;&lt;br /&gt;#include &amp;lt;IOKit/ps/IOPSKeys.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;#include &amp;lt;errno.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;lt;syslog.h&amp;gt;&lt;br /&gt;&lt;br /&gt;void printMemoryInfo()&lt;br /&gt;{&lt;br /&gt; size_t length;&lt;br /&gt; int mib[6]; &lt;br /&gt; int result;&lt;br /&gt;&lt;br /&gt; printf("Memory Info\n");&lt;br /&gt; printf("-----------\n");&lt;br /&gt;&lt;br /&gt; int pagesize;&lt;br /&gt; mib[0] = CTL_HW;&lt;br /&gt; mib[1] = HW_PAGESIZE;&lt;br /&gt; length = sizeof(pagesize);&lt;br /&gt; if (sysctl(mib, 2, &amp;pagesize, &amp;length, NULL, 0) &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt;  perror("getting page size");&lt;br /&gt; }&lt;br /&gt; printf("Page size = %d bytes\n", pagesize);&lt;br /&gt; printf("\n");&lt;br /&gt;&lt;br /&gt; mach_msg_type_number_t count = HOST_VM_INFO_COUNT;&lt;br /&gt; &lt;br /&gt; vm_statistics_data_t vmstat;&lt;br /&gt; if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&amp;vmstat, &amp;count) != KERN_SUCCESS)&lt;br /&gt; {&lt;br /&gt;  printf("Failed to get VM statistics.");&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; double total = vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count;&lt;br /&gt; double wired = vmstat.wire_count / total;&lt;br /&gt; double active = vmstat.active_count / total;&lt;br /&gt; double inactive = vmstat.inactive_count / total;&lt;br /&gt; double free = vmstat.free_count / total;&lt;br /&gt;&lt;br /&gt; printf("Total =    %8d pages\n", vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count);&lt;br /&gt; printf("\n");&lt;br /&gt; printf("Wired =    %8d bytes\n", vmstat.wire_count * pagesize);&lt;br /&gt; printf("Active =   %8d bytes\n", vmstat.active_count * pagesize);&lt;br /&gt; printf("Inactive = %8d bytes\n", vmstat.inactive_count * pagesize);&lt;br /&gt; printf("Free =     %8d bytes\n", vmstat.free_count * pagesize);&lt;br /&gt; printf("\n");&lt;br /&gt; printf("Total =    %8d bytes\n", (vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count) * pagesize);&lt;br /&gt; printf("\n");&lt;br /&gt; printf("Wired =    %0.2f %%\n", wired * 100.0);&lt;br /&gt; printf("Active =   %0.2f %%\n", active * 100.0);&lt;br /&gt; printf("Inactive = %0.2f %%\n", inactive * 100.0);&lt;br /&gt; printf("Free =     %0.2f %%\n", free * 100.0);&lt;br /&gt; printf("\n");&lt;br /&gt;&lt;br /&gt; mib[0] = CTL_HW;&lt;br /&gt; mib[1] = HW_PHYSMEM;&lt;br /&gt; length = sizeof(result);&lt;br /&gt; if (sysctl(mib, 2, &amp;result, &amp;length, NULL, 0) &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt;  perror("getting physical memory");&lt;br /&gt; }&lt;br /&gt; printf("Physical memory = %8d bytes\n", result);&lt;br /&gt; mib[0] = CTL_HW;&lt;br /&gt; mib[1] = HW_USERMEM;&lt;br /&gt; length = sizeof(result);&lt;br /&gt; if (sysctl(mib, 2, &amp;result, &amp;length, NULL, 0) &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt;  perror("getting user memory");&lt;br /&gt; }&lt;br /&gt; printf("User memory =     %8d bytes\n", result);&lt;br /&gt; printf("\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void printProcessorInfo()&lt;br /&gt;{&lt;br /&gt; size_t length;&lt;br /&gt; int mib[6]; &lt;br /&gt; int result;&lt;br /&gt;&lt;br /&gt; printf("Processor Info\n");&lt;br /&gt; printf("--------------\n");&lt;br /&gt;&lt;br /&gt; mib[0] = CTL_HW;&lt;br /&gt; mib[1] = HW_CPU_FREQ;&lt;br /&gt; length = sizeof(result);&lt;br /&gt; if (sysctl(mib, 2, &amp;result, &amp;length, NULL, 0) &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt;  perror("getting cpu frequency");&lt;br /&gt; }&lt;br /&gt; printf("CPU Frequency = %d hz\n", result);&lt;br /&gt; &lt;br /&gt; mib[0] = CTL_HW;&lt;br /&gt; mib[1] = HW_BUS_FREQ;&lt;br /&gt; length = sizeof(result);&lt;br /&gt; if (sysctl(mib, 2, &amp;result, &amp;length, NULL, 0) &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt;  perror("getting bus frequency");&lt;br /&gt; }&lt;br /&gt; printf("Bus Frequency = %d hz\n", result);&lt;br /&gt; printf("\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int printBatteryInfo()&lt;br /&gt;{&lt;br /&gt; CFTypeRef blob = IOPSCopyPowerSourcesInfo();&lt;br /&gt; CFArrayRef sources = IOPSCopyPowerSourcesList(blob);&lt;br /&gt; &lt;br /&gt; CFDictionaryRef pSource = NULL;&lt;br /&gt; const void *psValue;&lt;br /&gt; &lt;br /&gt; int numOfSources = CFArrayGetCount(sources);&lt;br /&gt; if (numOfSources == 0) {&lt;br /&gt;  perror("Error getting battery info");&lt;br /&gt;  return 1;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; printf("Battery Info\n");&lt;br /&gt; printf("------------\n");&lt;br /&gt;&lt;br /&gt; for (int i = 0 ; i &lt; numOfSources ; i++)&lt;br /&gt; {&lt;br /&gt;  pSource = IOPSGetPowerSourceDescription(blob, CFArrayGetValueAtIndex(sources, i));&lt;br /&gt;  if (!pSource) {&lt;br /&gt;   perror("Error getting battery info");&lt;br /&gt;   return 2;&lt;br /&gt;  }&lt;br /&gt;  psValue = (CFStringRef)CFDictionaryGetValue(pSource, CFSTR(kIOPSNameKey));&lt;br /&gt;  &lt;br /&gt;  int curCapacity = 0;&lt;br /&gt;  int maxCapacity = 0;&lt;br /&gt;  int percent;&lt;br /&gt;  &lt;br /&gt;  psValue = CFDictionaryGetValue(pSource, CFSTR(kIOPSCurrentCapacityKey));&lt;br /&gt;  CFNumberGetValue((CFNumberRef)psValue, kCFNumberSInt32Type, &amp;curCapacity);&lt;br /&gt;  &lt;br /&gt;  psValue = CFDictionaryGetValue(pSource, CFSTR(kIOPSMaxCapacityKey));&lt;br /&gt;  CFNumberGetValue((CFNumberRef)psValue, kCFNumberSInt32Type, &amp;maxCapacity);&lt;br /&gt;  &lt;br /&gt;  percent = (int)((double)curCapacity/(double)maxCapacity * 100);&lt;br /&gt;  &lt;br /&gt;  printf ("powerSource %d of %d: percent: %d/%d = %d%%\n", i+1, CFArrayGetCount(sources), curCapacity, maxCapacity, percent);&lt;br /&gt;  printf("\n");&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int printProcessInfo() {&lt;br /&gt;    int mib[5];&lt;br /&gt;    struct kinfo_proc *procs = NULL, *newprocs;&lt;br /&gt;    int i, st, nprocs;&lt;br /&gt;    size_t miblen, size;&lt;br /&gt;&lt;br /&gt;    /* Set up sysctl MIB */&lt;br /&gt;    mib[0] = CTL_KERN;&lt;br /&gt;    mib[1] = KERN_PROC;&lt;br /&gt;    mib[2] = KERN_PROC_ALL;&lt;br /&gt;    mib[3] = 0;&lt;br /&gt;    miblen = 4;&lt;br /&gt;&lt;br /&gt;    /* Get initial sizing */&lt;br /&gt;    st = sysctl(mib, miblen, NULL, &amp;size, NULL, 0);&lt;br /&gt;&lt;br /&gt;    /* Repeat until we get them all ... */&lt;br /&gt;    do {&lt;br /&gt;        /* Room to grow */&lt;br /&gt;        size += size / 10;&lt;br /&gt;        newprocs = realloc(procs, size);&lt;br /&gt;        if (!newprocs) {&lt;br /&gt;            if (procs) {&lt;br /&gt;                free(procs);&lt;br /&gt;            }&lt;br /&gt;            perror("Error: realloc failed.");&lt;br /&gt;            return (0);&lt;br /&gt;        }&lt;br /&gt;        procs = newprocs;&lt;br /&gt;        st = sysctl(mib, miblen, procs, &amp;size, NULL, 0);&lt;br /&gt;    } while (st == -1 &amp;&amp; errno == ENOMEM);&lt;br /&gt;&lt;br /&gt;    if (st != 0) {&lt;br /&gt;        perror("Error: sysctl(KERN_PROC) failed.");&lt;br /&gt;        return (0);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /* Do we match the kernel? */&lt;br /&gt;    assert(size % sizeof(struct kinfo_proc) == 0);&lt;br /&gt;&lt;br /&gt;    nprocs = size / sizeof(struct kinfo_proc);&lt;br /&gt;&lt;br /&gt;    if (!nprocs) {&lt;br /&gt;        perror("Error: printProcessInfo.");&lt;br /&gt;        return(0);&lt;br /&gt;    }&lt;br /&gt;    printf("  PID\tName\n");&lt;br /&gt;    printf("-----\t--------------\n");&lt;br /&gt;    for (i = nprocs-1; i &amp;gt;=0;  i--) {&lt;br /&gt;       printf("%5d\t%s\n",(int)procs[i].kp_proc.p_pid, procs[i].kp_proc.p_comm);&lt;br /&gt;    }&lt;br /&gt;    free(procs);&lt;br /&gt;    return (0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char **argv)&lt;br /&gt;{&lt;br /&gt; printf("iPhone Hardware Info\n");&lt;br /&gt; printf("====================\n");&lt;br /&gt; printf("\n");&lt;br /&gt; &lt;br /&gt; printMemoryInfo();&lt;br /&gt; printProcessorInfo();&lt;br /&gt; printBatteryInfo();&lt;br /&gt; printProcessInfo();&lt;br /&gt; return (0);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;MAC Address &amp; IP address of network interfaces&lt;/span&gt;&lt;br /&gt;original source from devforums.apple.com and modified to show IP address and exclude loopback addresses&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;macaddress.c  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;ifaddrs.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;br /&gt;#include &amp;lt;arpa/inet.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;#include &amp;lt;net/if.h&amp;gt;&lt;br /&gt;#include &amp;lt;net/if_dl.h&amp;gt;&lt;br /&gt;#include &amp;lt;arpa/inet.h&amp;gt;&lt;br /&gt;#include &amp;lt;ifaddrs.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#if ! defined(IFT_ETHER)&lt;br /&gt;#define IFT_ETHER 0x6/* Ethernet CSMACD */&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;int main(int argc, char **argv)&lt;br /&gt;{&lt;br /&gt;  bool success;&lt;br /&gt;  struct ifaddrs *addrs;&lt;br /&gt;  const struct ifaddrs *cursor;&lt;br /&gt;  const struct sockaddr_dl *dlAddr;&lt;br /&gt;  const uint8_t *base;&lt;br /&gt;  int i;&lt;br /&gt;&lt;br /&gt;  success = getifaddrs(&amp;addrs) == 0;&lt;br /&gt;  if (success) {&lt;br /&gt;    cursor = addrs;&lt;br /&gt;    while (cursor != NULL) {&lt;br /&gt;    if ((cursor-&amp;gt;ifa_flags &amp; IFF_LOOPBACK) == 0 ) {&lt;br /&gt;      printf("%s ", (char *)cursor-&amp;gt;ifa_name);&lt;br /&gt;      printf("%s\n",inet_ntoa(((struct sockaddr_in *)cursor-&amp;gt;ifa_addr)-&amp;gt;sin_addr));&lt;br /&gt;    }&lt;br /&gt;    if ( (cursor-&amp;gt;ifa_addr-&amp;gt;sa_family == AF_LINK)&lt;br /&gt;    &amp;&amp; (((const struct sockaddr_dl *) cursor-&amp;gt;ifa_addr)-&amp;gt;sdl_type ==IFT_ETHER)&lt;br /&gt;    ) {&lt;br /&gt;      dlAddr = (const struct sockaddr_dl *) cursor-&amp;gt;ifa_addr;&lt;br /&gt;//      fprintf(stderr, " sdl_nlen = %d\n", dlAddr-&amp;gt;sdl_nlen);&lt;br /&gt;//      fprintf(stderr, " sdl_alen = %d\n", dlAddr-&amp;gt;sdl_alen);&lt;br /&gt;      base = (const uint8_t *) &amp;dlAddr-&amp;gt;sdl_data[dlAddr-&amp;gt;sdl_nlen];&lt;br /&gt;      printf(" MAC address ");&lt;br /&gt;      for (i = 0; i &amp;lt; dlAddr-&amp;gt;sdl_alen; i++) {&lt;br /&gt;        if (i != 0) {&lt;br /&gt;          printf(":");&lt;br /&gt;        }&lt;br /&gt;        printf("%02x", base[i]);&lt;br /&gt;      } &lt;br /&gt;      printf("\n");&lt;br /&gt;    }&lt;br /&gt;    cursor = cursor-&amp;gt;ifa_next;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;There are also iPhone device info from the SDK in UIDevice.h&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;UIDevice.h  &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;+ (UIDevice *)currentDevice;&lt;br /&gt;@property(nonatomic,readonly,retain) NSString    *name;              // e.g. "My iPhone"&lt;br /&gt;@property(nonatomic,readonly,retain) NSString    *model;             // e.g. @"iPhone", @"iPod Touch"&lt;br /&gt;@property(nonatomic,readonly,retain) NSString    *localizedModel;    // localized version of model&lt;br /&gt;@property(nonatomic,readonly,retain) NSString    *systemName;        // e.g. @"iPhone OS"&lt;br /&gt;@property(nonatomic,readonly,retain) NSString    *systemVersion;     // e.g. @"2.0"&lt;br /&gt;@property(nonatomic,readonly) UIDeviceOrientation orientation;       // return current device orientation&lt;br /&gt;@property(nonatomic,readonly,retain) NSString    *uniqueIdentifier;  // a string unique to each device based on various hardware info.&lt;br /&gt;&lt;br /&gt;undocumented&lt;br /&gt;- (id)buildVersion;&lt;br /&gt;- (int)batteryState;&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2377894868937733044?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2377894868937733044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2377894868937733044' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2377894868937733044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2377894868937733044'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/source-code-get-hardware-info-of-iphone.html' title='Source Code : Get Hardware Info of iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-7205273626302312076</id><published>2009-01-12T22:12:00.024+08:00</published><updated>2009-04-09T13:47:47.720+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ARM'/><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='Inline Assembler'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone GCC'/><title type='text'>How-to do ARM GCC Inline Assembler for iPhone</title><content type='html'>The following code demonstrates an example to write Inline Assembler in llvm-gcc for iPhone ARM&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;arithmetic_shift_right.c  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=7205273626302312076#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt;  int i = atoi(argv[1]);&lt;br /&gt;  asm volatile ("mov %0, %1, ASR #1" : "=r"(i) : "r"(i));&lt;br /&gt;  printf("arithmetic_shift_right is %d\n", i);&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;The general format (&lt;a href="http://www.ethernut.de/en/documents/arm-inline-asm.html"&gt;ref&lt;/a&gt;) is&lt;br /&gt;asm volatile (assembler instructions : output operands (optional) : input operands (optional) : clobbered registers (optional) );&lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;asm volatile ("mul %0, %1, %2" : "=r" (result) : "r" (number1) , "r" (number2));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;This version is for Assembler Macro&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;arithmetic_shift_right.c  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=7205273626302312076#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;inline int arithmetic_shift_right(int a) {&lt;br /&gt; int y;&lt;br /&gt; __asm__("mov %0, %1, ASR #1" : "=r" (y) : "r" (a));&lt;br /&gt; // Register R0 will become the value of register R1 shifted to the right by 1 bit, with the sign maintained.&lt;br /&gt; return y;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt; int i = atoi(argv[1]);&lt;br /&gt; printf("arithmetic_shift_right %d is %d\n", i, arithmetic_shift_right(i));&lt;br /&gt; exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Below is the otool output for Assembler Macro&lt;/span&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;otool -tV  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=7205273626302312076#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;_arithmetic_shift_right:&lt;br /&gt;00001eb4 e92d4080 stmdb sp!, {r7, lr}&lt;br /&gt;00001eb8 e28d7000 add r7, sp, #0 ; 0x0&lt;br /&gt;00001ebc e24dd008 sub sp, sp, #8 ; 0x8&lt;br /&gt;00001ec0 e58d0000 str r0, [sp]&lt;br /&gt;00001ec4 e59d3000 ldr r3, [sp]&lt;br /&gt;00001ec8 e1a030c3 mov r3, r3, asr #1       @@ arithmetic shift right&lt;br /&gt;00001ecc e58d3004 str r3, [sp, #4]&lt;br /&gt;00001ed0 e59d3004 ldr r3, [sp, #4]&lt;br /&gt;00001ed4 e1a00003 mov r0, r3&lt;br /&gt;00001ed8 e247d000 sub sp, r7, #0 ; 0x0&lt;br /&gt;00001edc e8bd8080 ldmia sp!, {r7, pc}&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Below is the otool output for Assembler Macro (after full optimzation -O2)&lt;/span&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;otool -tV  &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=7205273626302312076#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;_arithmetic_shift_right:&lt;br /&gt;00001f04 e1a000c0 mov r0, r0, asr #1&lt;br /&gt;00001f08 e12fff1e bx lr&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Assembler Macro for more than one assembler instruction&lt;br /&gt;arithmetic shift right then perform 16 bit binary multiplication&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Assembler Macros &lt;a href="http://www.blogger.com/post-edit.g?blogID=6245963027152906987&amp;amp;postID=7205273626302312076#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt; __asm__("mov %0, %1, ASR #1\n\t"&lt;br /&gt;         "mul %0, %0, %1"&lt;br /&gt;         : "=r" (y) : "r" (a));&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-7205273626302312076?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/7205273626302312076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=7205273626302312076' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7205273626302312076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/7205273626302312076'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/how-to-do-arm-gcc-inline-assembler-for.html' title='How-to do ARM GCC Inline Assembler for iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-6635934670158221220</id><published>2009-01-07T16:50:00.022+08:00</published><updated>2009-01-29T01:26:28.411+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Emoji'/><title type='text'>Enable Emoji without jailbreak iPhone</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;There is no need to guess and wait for update. This patch works for firmware 2.2 / 2.2.1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Emoji is the Japanese name for pictorial characters, smileys and emoticons. The characters are similar to the commonly used emoticons &lt;img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/03.gif" /&gt; but Emoji contains over 461 icons. These icons are standardized and built into most japanese handsets.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3LRNVfBfliQ/SWR0qCIxPZI/AAAAAAAAApU/-c6TbdhUNk8/s1600-h/emoji.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 255px;" src="http://4.bp.blogspot.com/_3LRNVfBfliQ/SWR0qCIxPZI/AAAAAAAAApU/-c6TbdhUNk8/s400/emoji.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5288480127916785042" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Currently, this new feature for firmware 2.2 is available to Japanese iPhone 3G or jailbreak iPhone with emoji patch only.&lt;br /&gt;&lt;br /&gt;To enable Emoji without jailbreak, you need to install an app that I made.&lt;br /&gt;&lt;br /&gt;This is not a vcard.vcf method, this is a patch like the one in Cydia but available to iPhone and no jailbreak required.  The above screen dump is directly captured from my iPhone 3G, and no jailbreak.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 102, 0);"&gt;Touch Dial Emoji Version 1.2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To enable Emoji, follow these steps&lt;br /&gt;(1) Upgrade iPhone firmware to 2.2&lt;br /&gt;&lt;br /&gt;(2) Install Touch Dial Emoji version 1.2 from App Store&lt;br /&gt;iTunes Link &lt;a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=286534260&amp;amp;mt=8"&gt;http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=286534260&amp;amp;mt=8&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 102, 0);"&gt;Yes, you have to pay for this app. If you don't like to pay, jailbreak your iPhone and install the package from Cydia, it is free.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(3) Goto Settings -&amp;gt; Touch Dial -&amp;gt; turn Enable Smiley icon to ON&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(4) Launch Touch Dial &lt;img src="http://www.iphone.org.hk/attach/48911-Icon-embed.png" /&gt;&lt;br /&gt;&lt;br /&gt;(5) Go to Settings&amp;gt;General&amp;gt;Keyboard&amp;gt;International Keyboards&amp;gt;Japanese and enable "Emoji."&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/47361-EnableEmoji.png" width="600" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The difficulty of this app is not on coding as the method is well known, it is about how to get it past.&lt;br /&gt;&lt;br /&gt;One more thing, new hack is coming.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-6635934670158221220?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/6635934670158221220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=6635934670158221220' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6635934670158221220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/6635934670158221220'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/enable-emoji-without-jailbreak-iphone.html' title='Enable Emoji without jailbreak iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_3LRNVfBfliQ/SWR0qCIxPZI/AAAAAAAAApU/-c6TbdhUNk8/s72-c/emoji.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3464095133401602842</id><published>2009-01-07T14:42:00.020+08:00</published><updated>2009-11-25T07:57:14.369+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Codesign error'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><title type='text'>CodeSign error: a valid provisioning profile is required</title><content type='html'>&lt;span style="font-style:italic;"&gt;"CodeSign error: a valid provisioning profile is required for product type 'Application' in SDK 'Device - iPhone OS 2.2"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This error will appear when you update your provisioning profile in iPhone SDK 2.2&lt;br /&gt;or after the expiration of developer certificate and that you have a new provisioning profile from the developer portal&lt;br /&gt;&lt;br /&gt;This is the solution (which is modified from http://www.furmanek.net/54/iphone-sdk-22-codesign-error/)&lt;br /&gt;&lt;br /&gt;Suppose you have copied your provisioning profile called "iPhone_Development.mobileprovision" to the Library folder and build &amp;amp; go an old iPhone project called "MyApp", and this annoying error appears&lt;br /&gt;&lt;br /&gt;(1) &lt;code&gt;cd ~/Library/MobileDevice/Provisioning\ Profiles/&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(2) find out the UUID of the provisioning profile&lt;br /&gt;&lt;code&gt;strings iPhone_Development.mobileprovision | grep "&amp;lt;string&amp;gt;.*-.*&amp;lt;/string&amp;gt;"&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;output is like this&lt;br /&gt;&lt;code&gt;&amp;lt;string&amp;gt;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&amp;lt;/string&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) copy that UUID between the string tag&lt;br /&gt;&lt;br /&gt;(4) close xcode and go to your project&lt;br /&gt;&lt;code&gt;cd ~/Projects/MyApp/MyApp.xcodeproj&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(5) Use a text editor to open the project.pbxproj&lt;br /&gt;find the string &lt;span style="font-style:italic;"&gt;PROVISIONING_PROFILE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;paste the UUID that you copied from step (3) and put it in both Debug and Release Sections (do multiple finds) for the following line&lt;br /&gt;e.g.&lt;br /&gt;&lt;code&gt;PROVISIONING_PROFILE = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(6) Launch XCode and open the project and build &amp;amp; go again&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;Updates :&lt;br /&gt;Deleting all of the lines "PROVISIONING_PROFILE" in project.pbxproj will also fix the problem for iPhone SDK 3 or above&lt;/span&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3464095133401602842?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3464095133401602842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3464095133401602842' title='41 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3464095133401602842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3464095133401602842'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/codesign-error-valid-provisioning.html' title='CodeSign error: a valid provisioning profile is required'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>41</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2628925292551479636</id><published>2009-01-04T10:13:00.015+08:00</published><updated>2009-11-12T19:17:48.078+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='ldid'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='toolchain 2.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Makefile'/><title type='text'>UICatalog : Makefile for Apple sample iPhone SDK code</title><content type='html'>To check out UICatalog from Apple developer website or from here&lt;br /&gt;svn co -r16 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog&lt;br /&gt;&lt;br /&gt;The modification here is to show how to change the xib file to iphone code (as in revision 17) here&lt;br /&gt;&lt;a href="http://code.google.com/p/apiexplorer/source/detail?r=17"&gt;http://code.google.com/p/apiexplorer/source/detail?r=17&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Furthermore, if you checkout the revision 18, you can have the ldid binary and Makefiles for installation to iPhone /Applications folder&lt;br /&gt;Mac : (using Makefile.mac and ldid_mac)&lt;br /&gt;Linux toolchain : (using Makefile.linux and ldid_linux)&lt;br /&gt;iPhone gcc : (using Makefile.iphone and please install ldid package in Cydia)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Instructions to compile using Makefile for UICatalog under Mac&lt;/span&gt;&lt;br /&gt;(1) Checkout revision 18&lt;br /&gt;&lt;code&gt;svn co -r18 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(2) Install respring in iPhone (if haven't done so) assume your iphone ip is 10.0.2.2&lt;br /&gt;&lt;code&gt;make install_respring -f Makefile.mac IPHONE_IP=10.0.2.2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) modify the IPHONE_IP (to the actual IP address of iPhone) in Makefile.mac&lt;br /&gt;&lt;code&gt;IPHONE_IP=10.0.2.2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) make &amp; install&lt;br /&gt;&lt;code&gt;make -f Makefile.mac&lt;br /&gt;make install -f Makefile.mac&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you want to install your Mac / Linux public key in iPhone so as to avoid typing password using ssh, please refer to my previous &lt;a href="http://iphonesdkdev.blogspot.com/2008/12/how-to-compile-iphone-project-in-mac.html"&gt;post here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Instructions to compile using Makefile for UICatalog under Linux toolchain&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Please refer to these two articles in how to install toolchain in Linux&lt;br /&gt;&lt;a href="http://iphonesdkdev.blogspot.com/2008/11/upgrade-vmware-image-to-ubuntu-810-for.html"&gt;http://iphonesdkdev.blogspot.com/2008/11/upgrade-vmware-image-to-ubuntu-810-for.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://iphonesdkdev.blogspot.com/2008/10/how-to-install-llvm-gcc-for-iphone-sdk.htm"&gt;http://iphonesdkdev.blogspot.com/2008/10/how-to-install-llvm-gcc-for-iphone-sdk.htm&lt;/a&gt;l&lt;br /&gt;&lt;br /&gt;(1) Checkout revision 18&lt;br /&gt;&lt;code&gt;svn co -r18 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(2) Install respring in iPhone (if haven't done so) assume your iphone ip is 10.0.2.2&lt;br /&gt;&lt;code&gt;make install_respring -f Makefile.linux IPHONE_IP=10.0.2.2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) modify the IPHONE_IP  (to the actual IP address of iPhone) and toolchain  (to the toolchain folder location) in Makefile.linux&lt;br /&gt;&lt;code&gt;IPHONE_IP=10.0.2.2&lt;br /&gt;toolchain=/usr/toolchain2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) make &amp; install&lt;br /&gt;&lt;code&gt;make -f Makefile.linux&lt;br /&gt;make install -f Makefile.linux&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you want to install your Mac / Linux public key in iPhone so as to avoid typing password using ssh, please refer to my previous &lt;a href="http://iphonesdkdev.blogspot.com/2008/12/how-to-compile-iphone-project-in-mac.html"&gt;post here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Instructions to compile using Makefile for UICatalog under iPhone gcc&lt;/span&gt;&lt;br /&gt;Assume already install iphone gcc, ldid, make and subversion packages in Cydia and also have sdk headers / lib files&lt;br /&gt;&lt;br /&gt;(1) Checkout revision 18&lt;br /&gt;&lt;code&gt;svn co -r18 http://apiexplorer.googlecode.com/svn/trunk/UICatalog UICatalog&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(2) Install respring in iPhone (if haven't done so) &lt;br /&gt;&lt;code&gt;make install_respring -f Makefile.iphone&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) modify the SDK  (to the sdk headers and lib files location) in Makefile.iphone&lt;br /&gt;&lt;code&gt;SDK = /var/toolchain2/sys20&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) make &amp; install&lt;br /&gt;&lt;code&gt;make -f Makefile.iphone&lt;br /&gt;make install -f Makefile.iphone&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;P.S. There is a great tool here to convert .xib / *.nib to .m&lt;br /&gt;see here&lt;br /&gt;&lt;a href="http://github.com/akosma/nib2objc/tree/master"&gt;http://github.com/akosma/nib2objc/tree/master&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you need to compile ldid in Intel machine, here is how&lt;br /&gt;&lt;code&gt;&lt;br /&gt;wget http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.476.tgz&lt;br /&gt;tar -zxf ldid-1.0.476.tgz&lt;br /&gt;cd ldid-1.0.476&lt;br /&gt;g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c&lt;br /&gt;sudo cp -a util/ldid /usr/bin&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;For PowerPC, you need the patch file here&lt;br /&gt;http://fink.cvs.sourceforge.net/viewvc/*checkout*/fink/dists/10.4/unstable/crypto/finkinfo/ldid.patch?revision=1.1&lt;br /&gt;&lt;br /&gt;and to apply the patch before compilation, use this&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -O http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.476.tgz&lt;br /&gt;tar -zxf ldid-1.0.476.tgz&lt;br /&gt;wget -qO- http://fink.cvs.sourceforge.net/viewvc/*checkout*/fink/dists/10.4/unstable/crypto/finkinfo/ldid.patch?revision=1.1 | patch -p0&lt;br /&gt;cd ldid-1.0.476&lt;br /&gt;g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c&lt;br /&gt;sudo cp -a util/ldid /usr/bin&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Updates : The source of of ldid is moved to here&lt;br /&gt;wget http://www.telesphoreo.org/export/477/trunk/data/ldid/ldid-1.0.476.tgz&lt;br /&gt;or updated one here&lt;br /&gt;wget http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.610.tgz&lt;br /&gt;&lt;br /&gt;Updates : If you compiled it in cgywin, you need to add (uint32_t) in the source code ldid.cpp that has ambiguous overload call error message like this&lt;br /&gt;&lt;code&gt;&lt;br /&gt;error: call of overloaded 'Swap(int)' is ambiguous&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2628925292551479636?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2628925292551479636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2628925292551479636' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2628925292551479636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2628925292551479636'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/uicatalog-makefile-for-apple-sample.html' title='UICatalog : Makefile for Apple sample iPhone SDK code'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2672927488652823044</id><published>2009-01-02T15:04:00.019+08:00</published><updated>2009-12-26T02:17:28.704+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='subversion'/><title type='text'>How-to create svn server (subversion) in iPhone</title><content type='html'>This guide shows you how to setup svn+ssh server in pwned iPhone&lt;br /&gt;&lt;br /&gt;(1) Install subversion package in Cydia&lt;br /&gt;&lt;code&gt;apt-get install subversion&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(2) create repository in iPhone (e.g. with the Project called UICatalog)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mkdir -p /var/root/Library/Subversion/Repository&lt;br /&gt;svnadmin create /var/root/Library/Subversion/Repository/UICatalog&lt;br /&gt;mkdir -p /tmp/UICatalog/trunk /tmp/UICatalog/branches /tmp/UICatalog/tags&lt;br /&gt;svn import /tmp/UICatalog/ file:///var/root/Library/Subversion/Repository/UICatalog -m "Create Directory Structure"&lt;br /&gt;rm -rf /tmp/UICatalog&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) Import Project directory&lt;br /&gt;import from iPhone&lt;br /&gt;&lt;code&gt;svn import UICatalog file:///var/root/Library/Subversion/Repository/UICatalog/trunk -m "Import project dir from iPhone"&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;import from Mac (assume iPhone IP is 10.0.2.2)&lt;br /&gt;&lt;code&gt;svn import UICatalog svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk -m "Import project dir from Mac"&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(4) Checkout Project directory&lt;br /&gt;checkout to Mac (assume iPhone IP is 10.0.2.2)&lt;br /&gt;&lt;code&gt;svn checkout svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk UICatalog&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;checkout a specific revision 5 to Mac (assume iPhone IP is 10.0.2.2)&lt;br /&gt;&lt;code&gt;svn co -r 5 svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk UICatalogR2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;checkout to iPhone to another dir&lt;br /&gt;&lt;code&gt;svn checkout file:///var/root/Library/Subversion/Repository/UICatalog/trunk UICatalog2&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;checkout a specific revision 5 to iPhone&lt;br /&gt;&lt;code&gt;svn co -r 5 file:///var/root/Library/Subversion/Repository/UICatalog/trunk UICatalog_v5&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(5)Other useful svn commands&lt;br /&gt;(change directory to the working copy that was checkout in iPhone)&lt;br /&gt;&lt;code&gt;cd UICatalog2&lt;br /&gt;svn info&lt;br /&gt;svn commit -m 'commit changes'&lt;br /&gt;svn ls file:///var/root/Library/Subversion/Repository/UICatalog/trunk&lt;br /&gt;svn log&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(change directory to the working copy that was checkout in Mac)&lt;br /&gt;&lt;code&gt;cd UICatalog&lt;br /&gt;svn add newfile.m&lt;br /&gt;svn info&lt;br /&gt;svn commit -m 'commit changes'&lt;br /&gt;svn ls svn+ssh://root@10.0.2.2/var/root/Library/Subversion/Repository/UICatalog/trunk&lt;br /&gt;svn log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(6) svn to googlecode.com&lt;br /&gt;&lt;code&gt;svn checkout https://&amp;lt;yourproject&amp;gt;.googlecode.com/svn/trunk/&amp;lt;yourprojectdirname&amp;gt; --username &amp;lt;your username without @gmail.com&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;When prompted, enter your generated googlecode.com password.&lt;br /&gt;The googlecode.com svn password is in the googlecode.com (it is not the same as the gmail password)&lt;br /&gt;&lt;br /&gt;Profile -&gt; Settings&lt;br /&gt;&lt;br /&gt;&lt;code&gt;cd &amp;lt;yourprojectdirname&amp;gt;&lt;br /&gt;svn add newfile.m&lt;br /&gt;svn commit -m 'commit changes: adding newfile.m'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;import to a subdirectory&lt;br /&gt;&lt;code&gt;svn import &amp;lt;yourprojectdirname&amp;gt; https://&amp;lt;yourproject&amp;gt;.googlecode.com/svn/trunk/&amp;lt;yourprojectdirname&amp;gt;/ --username &amp;lt;your username without @gmail.com&amp;gt&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;delete directory/files that were in the wrong place&lt;br /&gt;&lt;code&gt;svn delete -m "Deleting wrong place commit" https://&amp;lt;yourproject&amp;gt;.googlecode.com/svn/trunk/&amp;lt;directorytobedeleted&amp;gt; https://&amp;lt;yourproject&amp;gt;.googlecode.com/svn/trunk/&amp;lt;filetobedeleted&amp;gt; ....&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(7) Others&lt;br /&gt;The use of Xcode 3 and subversion is in Apple documentation here&lt;br /&gt;&lt;a href="http://developer.apple.com/mac/articles/server/subversionwithxcode3.html"&gt;http://developer.apple.com/mac/articles/server/subversionwithxcode3.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can make use of this to manage SCM for XCode project to google code, Mac or iPhone&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(8) GIT&lt;br /&gt;If you need git on leopard, here&lt;br /&gt;&lt;a href="http://code.google.com/p/git-osx-installer/"&gt;http://code.google.com/p/git-osx-installer/&lt;/a&gt;&lt;br /&gt;or use &lt;a href="http://www.apple.com/downloads/macosx/unix_open_source/macports.html"&gt;MacPorts&lt;/a&gt; (port install git-core)&lt;br /&gt;&lt;br /&gt;or you can compile and install from source&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mkdir ~/src&lt;br /&gt;cd ~/src/&lt;br /&gt;curl -O http://kernel.org/pub/software/scm/git/git-1.6.5.3.tar.bz2&lt;br /&gt;tar -xjvf git-1.6.5.3.tar.bz2&lt;br /&gt;cd git-1.6.5.3&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;git --version&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2672927488652823044?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2672927488652823044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2672927488652823044' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2672927488652823044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2672927488652823044'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/how-to-create-svn-server-subversion-in.html' title='How-to create svn server (subversion) in iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3488821189960125531</id><published>2009-01-01T22:37:00.013+08:00</published><updated>2009-02-22T18:37:52.841+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cocos2d'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><title type='text'>XCode Template for cocos2d</title><content type='html'>This open source game Libray is for you to development games for iPhone using XCode. The current version is 0.6.2&lt;br /&gt;&lt;br /&gt;The project source is here&lt;br /&gt;&lt;a href="http://code.google.com/p/cocos2d-iphone/"&gt;http://code.google.com/p/cocos2d-iphone/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;These are the features of the library:&lt;br /&gt;  * Scene management (workflow)&lt;br /&gt;  * Transitions between scenes&lt;br /&gt;  * Sprites&lt;br /&gt;  * Actions&lt;br /&gt;  * Basic menus and buttons&lt;br /&gt;  * Integrated Chipmunk 2d physics engine&lt;br /&gt;  * Particle system&lt;br /&gt;  * Text rendering support&lt;br /&gt;  * Texture Atlas support&lt;br /&gt;  * Tile Map support&lt;br /&gt;  * Parallax scrolling&lt;br /&gt;  * Touch/Accelerometer support&lt;br /&gt;  * Portrait and Landscape mode&lt;br /&gt;  * Integrated Pause/Resume&lt;br /&gt;  * Supports PowerVR Texture Compression (PVRTC) format&lt;br /&gt;  * Language: objective-c&lt;br /&gt;  * Open Source: Compatible with open and closed source projects&lt;br /&gt;  * OpenGL ES 1.1 based&lt;br /&gt;&lt;br /&gt;Here is the XCode Template, so that you can create new project and start 2d game programming&lt;br /&gt;&lt;br /&gt;Installation Instruction of this XCode Template for cocos2d 0.62&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -O http://apiexplorer.googlecode.com/files/cocos2d.zip&lt;br /&gt;unzip cocos2d.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Here is a quick primer guide to start development with a simple game using cocos2d, this XCode template is also created based on the method as described in this article&lt;br /&gt;&lt;a href="http://monoclestudios.com/cocos2d_whitepaper.html"&gt;http://monoclestudios.com/cocos2d_whitepaper.html &lt;/a&gt;&lt;br /&gt;and these two as well&lt;br /&gt;&lt;a href="http://lethain.com/entry/2008/oct/03/notes-on-cocos2d-iphone-development/"&gt;http://lethain.com/entry/2008/oct/03/notes-on-cocos2d-iphone-development/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://lethain.com/entry/2008/oct/20/touch-detection-in-cocos2d-iphone/"&gt;http://lethain.com/entry/2008/oct/20/touch-detection-in-cocos2d-iphone/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After installation of this XCode Template, you can create new project for cocos2d library&lt;br /&gt;&lt;br /&gt;A Makefile is also included so that you can build the created new project and ldid fake codeign and install in the /Application folder of iPhone&lt;br /&gt;&lt;br /&gt;(1) you need to change the IPHONE_IP in the Makefile&lt;br /&gt;(2) make install_respring&lt;br /&gt;(3) make&lt;br /&gt;(4) make install&lt;br /&gt;&lt;br /&gt;If you want to install your Mac public key in iPhone so as to avoid typing password using ssh, please refer to my previous &lt;a href="http://iphonesdkdev.blogspot.com/2008/12/how-to-compile-iphone-project-in-mac.html"&gt;post here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The api documentation of cocos2d are here&lt;br /&gt;&lt;a href="http://groups.google.com/group/cocos2d-iphone-discuss"&gt;http://groups.google.com/group/cocos2d-iphone-discuss &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;Update : Cocos2d v0.7 XCode Template&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -O http://apiexplorer.googlecode.com/files/cocos2d_v0.7.zip&lt;br /&gt;unzip cocos2d_v0.7.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This new XCode Template v0.7 has been restructured so that when cocos2d is updated in the future, you can just copy the new cocos2d directory and replace the cocos2d-iphone in the old project directory e.g.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cp -r ~/Downloads/cocos2d-iphone-0.8/* ~/Projects/myproject/cocos2d-iphone/&lt;br /&gt;rm -fr ~/Projects/myproject/cocos2d-iphone/cocos2d-iphone.xcodeproj&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3488821189960125531?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3488821189960125531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3488821189960125531' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3488821189960125531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3488821189960125531'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2009/01/xcode-template-for-cocos2d.html' title='XCode Template for cocos2d'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2110934107510143140</id><published>2008-12-22T12:03:00.011+08:00</published><updated>2010-06-16T11:31:15.888+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone SDK'/><title type='text'>iPhone SDK 2.2 API Explorer</title><content type='html'>API Explorer is an iPhone App for searching SDK API, version 1 is written by Patrick Collison &lt;br /&gt;&lt;br /&gt;&lt;a href="http://collison.ie/blog/2008/10/iphone-hackery-api-explorer"&gt;http://collison.ie/blog/2008/10/iphone-hackery-api-explorer&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;git clone http://code.collison.ie/git/explorer/.git&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;I have enhanced it to version 1.2.1 with addition of searchbox and on-line reference to Erica Sadun 2.2 class documentation &lt;br /&gt;and some bug fixes&lt;br /&gt;&lt;br /&gt;Installation Instructions: &lt;br /&gt;&lt;br /&gt;Cydia Source : http://cydia.iphone.org.hk/apt/ &lt;br /&gt;Section: Utilities &lt;br /&gt;Name: API Explorer &lt;br /&gt;&lt;br /&gt;Source code for version 1.2.1 is here&lt;br /&gt;&lt;a href="http://www.iphone.org.hk/attach/48276-explorer-1.2.1.zip"&gt;http://www.iphone.org.hk/attach/48276-explorer-1.2.1.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SVN repository is here&lt;br /&gt;&lt;a href="http://code.google.com/p/apiexplorer/"&gt;http://code.google.com/p/apiexplorer/&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;img src="http://www.iphone.org.hk/attach/62581-apiexplorer3-embed.png"/&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2110934107510143140?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2110934107510143140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2110934107510143140' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2110934107510143140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2110934107510143140'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2008/12/iphone-sdk-api-explorer.html' title='iPhone SDK 2.2 API Explorer'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3001408332372535397</id><published>2008-12-20T17:20:00.010+08:00</published><updated>2008-12-20T18:04:29.209+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sample Code'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective C 2.0'/><title type='text'>property and synthesize directives in Objective C 2.0</title><content type='html'>&lt;span class="Apple-style-span" style="color: rgb(255, 102, 0);"&gt;@property directive is to declare a property&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;@interface Test : NSObject {&lt;br /&gt;}&lt;br /&gt;@property (readwrite,assign) int &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var1&lt;/span&gt;&lt;br /&gt;@property (readonly,assign) int &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var2&lt;/span&gt;&lt;br /&gt;@property (getter=foo, setter=foo1:) int &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var3&lt;/span&gt;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 0);"&gt;readwrite&lt;/span&gt; attribute (default) tells the compiler to generate both getter and setter accessors&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 0);"&gt;readonly&lt;/span&gt; attribute tells the compiler not to generate a setter accessor&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 0);"&gt;assign&lt;/span&gt; attribute to implement set-by-assignment (i.e. generate setter and simply assigns a value to the instance variable)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;-(void) setVar1:(NSString *)s&lt;br /&gt;{&lt;br /&gt;     var1 = s;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 0);"&gt;copy&lt;/span&gt; attribute to implement set-by-copy (usually for mutable object)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;-(void) setVar1:(NSString *)s&lt;br /&gt;{&lt;br /&gt;     [var1 release];&lt;br /&gt;     var1 = [s copy];&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 0);"&gt;retain&lt;/span&gt; attribute to implement set-by-retainment (i.e. generate setter and retain a value before assignment)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;-(void) setVar1:(NSString *)s&lt;br /&gt;{&lt;br /&gt;     [s retain];&lt;br /&gt;     [var1 release];&lt;br /&gt;     var1 = s;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 153, 0);"&gt;@synthesize directive is to make the compiler generate accessors&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@implementation Test&lt;br /&gt;@synthesize &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var1&lt;/span&gt;;&lt;br /&gt;@synthesize &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var2&lt;/span&gt;;&lt;br /&gt;@dynamic &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var3&lt;/span&gt;;&lt;br /&gt;@end&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;By Default, these messages are named &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var1&lt;/span&gt; and &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;setVar1&lt;/span&gt; where &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;var1&lt;/span&gt; is the name of the variable&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 0);"&gt;dynamic&lt;/span&gt; attribute tells the compiler not to generate any accessor messages&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Here is a good guideline for memory management in Cocoa&lt;br /&gt;&lt;a href="http://oreilly.com/pub/a/mac/excerpt/Cocoa_ch04/index.html"&gt;http://oreilly.com/pub/a/mac/excerpt/Cocoa_ch04/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Retention Count rules&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Within a given block, the use of -copy, -alloc and -retain should equal the use of -release and -autorelease.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Objects created using convenience constructors (e.g. NSString's stringWithString) are considered autoreleased.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Implement a -dealloc method to release the instance variables you own&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;retain increases the reference count of an object by 1&lt;br /&gt;&lt;/li&gt;&lt;li&gt;release decreases the reference count of an object by 1&lt;br /&gt;&lt;/li&gt;&lt;li&gt;autorelease decreases the reference count of an object by 1 at some stage in the future&lt;br /&gt;&lt;/li&gt;&lt;li&gt;alloc  allocates memory for an object, and returns it with retain count of 1&lt;br /&gt;&lt;/li&gt;&lt;li&gt;copy  makes a copy of an object, and returns it with retain count of 1&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3001408332372535397?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3001408332372535397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3001408332372535397' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3001408332372535397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3001408332372535397'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2008/12/property-and-synthesize-directives-in.html' title='property and synthesize directives in Objective C 2.0'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-3336861293672090339</id><published>2008-12-20T12:30:00.025+08:00</published><updated>2010-04-25T19:25:55.398+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='toolchain 2.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Makefile'/><title type='text'>How-To compile iPhone Project in Mac using Makefile instead of Xcode and fake codesign and then install to pwned iPhone</title><content type='html'>You can use the command line xcodebuild to build and install iPhone project such as&lt;br /&gt;&lt;br /&gt;&lt;code&gt;xcodebuild -target Project_Name&lt;br /&gt;xcodebuild install -target Project_Name&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Here is an example to compile iPhone Project using Makefile instead of XCode.&lt;br /&gt;&lt;br /&gt;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&lt;br /&gt;&lt;br /&gt;Location of files&lt;br /&gt;----------------&lt;br /&gt;Classes : source code (.m .c .cpp etc)&lt;br /&gt;Resources : png file and other support files&lt;br /&gt;Project folder : *.xib Info.plist&lt;br /&gt;&lt;br /&gt;(1) First you need to download this sample zip file and extract it to your Mac and cd to the directory&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl -O http://www.iphone.org.hk/attach/48150-PeoplePickerDemo.zip&lt;br /&gt;unzip 48150-PeoplePickerDemo.zip&lt;br /&gt;cd PeoplePickerDemo&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(3) Change the IPHONE_IP in the Makefile to the IP address of iPhone, default is 10.0.2.2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;dl class="codebox"&gt;&lt;dt&gt;Makefile: &lt;a href="#" onclick="selectCode(this); return false;"&gt;Select all&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;code&gt;&lt;br /&gt;IPHONE_IP=10.0.2.2&lt;br /&gt;&lt;br /&gt;SDKVER=2.0&lt;br /&gt;SDK=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(SDKVER).sdk&lt;br /&gt;&lt;br /&gt;CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1&lt;br /&gt;CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-g++-4.0.1&lt;br /&gt;LD=$(CC)&lt;br /&gt;&lt;br /&gt;LDFLAGS += -framework CoreFoundation &lt;br /&gt;LDFLAGS += -framework Foundation &lt;br /&gt;LDFLAGS += -framework UIKit &lt;br /&gt;LDFLAGS += -framework CoreGraphics&lt;br /&gt;LDFLAGS += -framework AddressBookUI&lt;br /&gt;LDFLAGS += -framework AddressBook&lt;br /&gt;//LDFLAGS += -framework QuartzCore&lt;br /&gt;//LDFLAGS += -framework GraphicsServices&lt;br /&gt;//LDFLAGS += -framework CoreSurface&lt;br /&gt;//LDFLAGS += -framework CoreAudio&lt;br /&gt;//LDFLAGS += -framework Celestial&lt;br /&gt;//LDFLAGS += -framework AudioToolbox&lt;br /&gt;//LDFLAGS += -framework WebCore&lt;br /&gt;//LDFLAGS += -framework WebKit&lt;br /&gt;//LDFLAGS += -framework SystemConfiguration&lt;br /&gt;//LDFLAGS += -framework CFNetwork&lt;br /&gt;//LDFLAGS += -framework MediaPlayer&lt;br /&gt;//LDFLAGS += -framework OpenGLES&lt;br /&gt;//LDFLAGS += -framework OpenAL&lt;br /&gt;&lt;br /&gt;LDFLAGS += -L"$(SDK)/usr/lib"&lt;br /&gt;LDFLAGS += -F"$(SDK)/System/Library/Frameworks"&lt;br /&gt;LDFLAGS += -F"$(SDK)/System/Library/PrivateFrameworks"&lt;br /&gt;&lt;br /&gt;CFLAGS += -I"/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/"&lt;br /&gt;CFLAGS += -I"$(SDK)/usr/include"&lt;br /&gt;CFLAGS += -I"/Developer/Platforms/iPhoneOS.platform/Developer/usr/include/"&lt;br /&gt;CFLAGS += -I"/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(SDKVER).sdk/usr/include"&lt;br /&gt;CFLAGS += -DDEBUG -std=c99&lt;br /&gt;CFLAGS += -Diphoneos_version_min=2.0&lt;br /&gt;CFLAGS += -F"$(SDK)/System/Library/Frameworks"&lt;br /&gt;CFLAGS += -F"$(SDK)/System/Library/PrivateFrameworks"&lt;br /&gt;&lt;br /&gt;CPPFLAGS=$CFLAGS&lt;br /&gt;&lt;/code&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;(4) install respring utility in iPhone&lt;br /&gt;&lt;code&gt;make install_respring&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(5) run make and make install&lt;br /&gt;&lt;code&gt;make&lt;br /&gt;make install&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(6) Test launch the app Demo in iPhone&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;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&lt;br /&gt;&lt;br /&gt;(a) keygen in Mac terminal and type (if you haven't generated it before)&lt;br /&gt;&lt;code&gt;ssh-keygen -t rsa&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You will be asked to enter a passphrase, please remember that if you enter that.&lt;br /&gt;&lt;br /&gt;(b) create .ssh directory in iPhone (assume ip address of iPhone is 10.0.2.2) and in Mac terminal and type&lt;br /&gt;&lt;code&gt;ssh root@10.0.2.2 'mkdir -p .ssh'&lt;/code&gt;&lt;br /&gt;then enter iPhone root password (alpine)&lt;br /&gt;&lt;br /&gt;(c) copy mac public key to iPhone, and in Mac Terminal type&lt;br /&gt;&lt;code&gt;cat ~/.ssh/id_rsa.pub | ssh root@10.0.2.2 'cat &gt;&gt; .ssh/authorized_keys'&lt;/code&gt;&lt;br /&gt;then enter iPhone root password (alpine)&lt;br /&gt;&lt;br /&gt;(d) Edit the file /etc/ssh/sshd_config in &lt;span class="Apple-style-span" style="color: rgb(255, 153, 0);"&gt;iPhone&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;change these&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#StrictModes yes&lt;br /&gt;#PubkeyAuthentication yes&lt;br /&gt;#AuthorizedKeysFile      .ssh/authorized_keys&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;StrictModes no&lt;br /&gt;PubkeyAuthentication yes&lt;br /&gt;AuthorizedKeysFile      .ssh/authorized_keys&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(e)reboot iPhone&lt;br /&gt;&lt;br /&gt;If you don't reboot, you can restart sshd using&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd /Library/LaunchDaemons/&lt;br /&gt;launchctl unload com.openssh.sshd.plist ; launchctl load com.openssh.sshd.plist&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To compile ldid in Power PC, do this&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;wget http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.476.tgz&lt;br /&gt;&lt;br /&gt;tar -zxf ldid-1.0.476.tgz&lt;br /&gt;&lt;br /&gt;# this patch is for PowerPC only&lt;br /&gt;wget -qO- http://fink.cvs.sourceforge.net/viewvc/*checkout*/fink/dists/10.4/unstable/crypto/finkinfo/ldid.patch?revision=1.1 | patch -p0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;cd ldid-1.0.476&lt;br /&gt;&lt;br /&gt;g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c&lt;br /&gt;&lt;br /&gt;sudo cp -a util/ldid /usr/bin&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-3336861293672090339?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/3336861293672090339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=3336861293672090339' title='30 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3336861293672090339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/3336861293672090339'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2008/12/how-to-compile-iphone-project-in-mac.html' title='How-To compile iPhone Project in Mac using Makefile instead of Xcode and fake codesign and then install to pwned iPhone'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>30</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6245963027152906987.post-2169516864962148296</id><published>2008-12-02T16:56:00.012+08:00</published><updated>2008-12-03T10:10:11.100+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Xcode'/><category scheme='http://www.blogger.com/atom/ns#' term='Touch Fighter'/><title type='text'>Touch Fighter 2 source code</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3LRNVfBfliQ/STUqKu6pQ9I/AAAAAAAAAl8/gTsUTLPsAJQ/s1600-h/touchfigher1.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 215px;" src="http://3.bp.blogspot.com/_3LRNVfBfliQ/STUqKu6pQ9I/AAAAAAAAAl8/gTsUTLPsAJQ/s400/touchfigher1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5275168902415467474" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A 2 week, 10,000+ lines coding done by Apple to demonstrate the graphics and audio capabilities of the iPhone for gaming.&lt;br /&gt;&lt;a href="http://youtube.com/watch?v=jn83wizEMAw"&gt;YouTube: iPhone SDK Demo - Touch Fighter&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The link may only be for Tech Talk attendees or ADC Member but if it works for you, enjoy.&lt;br /&gt;&lt;br /&gt;Here is the link to download.&lt;br /&gt;&lt;a href="https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?fileID=24200"&gt;https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?fileID=24200&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6245963027152906987-2169516864962148296?l=iphonesdkdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iphonesdkdev.blogspot.com/feeds/2169516864962148296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6245963027152906987&amp;postID=2169516864962148296' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2169516864962148296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6245963027152906987/posts/default/2169516864962148296'/><link rel='alternate' type='text/html' href='http://iphonesdkdev.blogspot.com/2008/12/touch-fighter-2-source-code.html' title='Touch Fighter 2 source code'/><author><name>javacom</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.c
