2011年8月30日 星期二

UIDevice detect the specific model ~識別設備機型


#import <sys/utsname.h>
NSString*
machineName()
{
    struct utsname systemInfo;
    uname(&systemInfo);

    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}

結果:
@"i386" on the simulator  (我的出現x86_64)
@"iPod1,1" on iPod Touch
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPhone3,1" on iPhone 4.
@"iPad2,1" on iPad2

UIRequiredDeviceCapabilities 指定程序需要那些設備







Key 說明

telephony(電話) Include this key if your application requires (or specifically prohibits) the presence of the Phone application. You might require this feature if your application opens URLs with the tel scheme

wifi Include this key if your application requires (or specifically prohibits) access to the networking features of the device.

sms Include this key if your application requires (or specifically prohibits) the presence of the Messages application. You might require this feature if your application opens URLs with the sms scheme.

still-camera Include this key if your application requires (or specifically prohibits) the presence of a camera on the device. Applications use the UIImagePickerController interface to capture images from the device’s still camera.

auto-focus-camera Include this key if your application requires (or specifically prohibits) auto-focus capabilities in the device’s still camera. Although most developers should not need to include this key, you might include it if your application supports macro photography or requires sharper images in order to do some sort of image processing.

front-facing-camera Include this key if your application requires (or specifically prohibits) the presence of a forward-facing camera. Applications use the UIImagePickerController interface to capture video from the device’s camera.

camera-flash(相機閃光燈) Include this key if your application requires (or specifically prohibits) the presence of a camera flash for taking pictures or shooting video. Applications use the UIImagePickerController interface to control the enabling of this feature.

video-camera Include this key if your application requires (or specifically prohibits) the presence of a camera with video capabilities on the device. Applications use the UIImagePickerController interface to capture video from the device’s camera.

accelerometer(加速度計) Include this key if your application requires (or specifically prohibits) the presence of accelerometers on the device. Applications use the classes of the Core Motion framework to receive accelerometer events. You do not need to include this key if your application detects only device orientation changes.

gyroscope(陀螺儀) Include this key if your application requires (or specifically prohibits) the presence of a gyroscope on the device. Applications use the Core Motion framework to retrieve information from gyroscope hardware.

location-services(定位服務) Include this key if your application requires (or specifically prohibits) the ability to retrieve the device’s current location using the Core Location framework. (This key refers to the general location services feature. If you specifically need GPS-level accuracy, you should also include the gps key.)

gps Include this key if your application requires (or specifically prohibits) the presence of GPS (or AGPS) hardware for greater accuracy when tracking locations. If you include this key, you should also include the location-services key. You should require GPS only if your application needs more accurate location data than the cell or Wi-fi radios might otherwise allow.

magnetometer(磁力儀) Include this key if your application requires (or specifically prohibits) the presence of magnetometer hardware. Applications use this hardware to receive heading-related events through the Core Location framework.

microphone Include this key if your application uses the built-in microphone or supports accessories that provide a microphone.

opengles-1 Include this key if your application requires (or specifically prohibits) the presence of the OpenGL ES 1.1 interfaces.

opengles-2 Include this key if your application requires (or specifically prohibits) the presence of the OpenGL ES 2.0 interfaces.

armv6 Include this key if your application is compiled only for the armv6 instruction set. (iOS v3.1 and later.)

armv7 Include this key if your application is compiled only for the armv7 instruction set. (iOS v3.1 and later.)

peer-peer Include this key if your application requires (or specifically prohibits) peer-to-peer connectivity over Bluetooth. (iOS v3.1 and later.)


提交app時可以在info.plist設置 

2011年8月23日 星期二

This generally means that another instance of this process was already running or is hung in the debugger

今天在測式時 crash之後
再編譯時就一直出現Error

This generally means that another instance of this process was already running or is hung in the debugger


實體機上沒有看到在跑任何程式丫~
但就是重編不了~
最後是裝置關機重開才行~

2011年8月22日 星期一

iOS設備內存硬體









設備 CPU 螢幕顯示 內存

1代 412MHz 480X320 128MB

iPhone3G 412MHz 480X320 128MB

iPod Touch 532MHz 480X320 128MB

iPhone3GS 600MHz  480X320 256MB

iPad 1GHz 1024X768 256MB

iPhone4 1GHz 960X640 512MB

ipad2 1GHz 雙核心 Apple A5 1024X768 512MB









如果要寫iphone程式,最好以128MB內存來思考,而且還要扣iOS系統佔用的
除非放棄iPhone3G、iPod Touch ~
而iPad程式呢~就要以256MB來思考,沒錯~iPad1的畫面比較大
,但可用就的內存就是比iPhone4來的少~~~~冏~~

2011年8月8日 星期一

真機調試 Received memory warning. Level= …

OSMemoryNotification.h

typedef enum {
OSMemoryNotificationLevelAny = -1,
OSMemoryNotificationLevelNormal = 0,
OSMemoryNotificationLevelWarning = 1,
OSMemoryNotificationLevelUrgent = 2,
OSMemoryNotificationLevelCritical = 3
} OSMemoryNotificationLevel;



How the levels are triggered is not documented. SpringBoard is configured to do the following in each memory level:

1.Warning (not-normal) — Relaunch, or delay auto relaunch of nonessential background apps e.g. Mail.
2.Urgent — Quit all background apps, e.g. Safari and iPod.
3.Critical and beyond — The kernel will take over, probably killing SpringBoard or even reboot.
4.Killing the active app (jetsam) is not handled by SpringBoard, but launchd.


參考文章

在cocos2d呢
1 .Received memory warning. Level= 1
會觸發 [[CCDirector sharedDirector] purgeCachedData];

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[CCDirector sharedDirector] purgeCachedData];
}


此時會把目前沒用到的 材質釋放掉~~
~
理論上ios系統會把不必要的背景程式關掉~


遇到這個情形呢~ 先查查leak吧
如果都沒有~就就就就…砍需求or改需求or改code~~~
減少在同一畫面下的內存使用量了


2 .Received memory warning. Level= 2


目前遇到的都crash 掉了~

還是乖乖查leak …





其他的還沒遇過~哈