iOS的SQLite操作

来源:互联网 发布:圣火明尊翅膀进阶数据 编辑:程序博客网 时间:2024/05/16 05:47

1:把东西复制到bundle之外,iPhone模拟器的沙漏安全和真机存在差别的

Your application bundle is not writable on the iPhone. You MUST copy the file somewhere else, like your documents folder. It works in the simulator because the Mac does not enforce all the sandboxing restrictions the iPhone does.

2:50M一个数据库文件的问题,众说风云啊 

Most of these answers are totally wrong. Safari will not allow you to create SQLite databases over 50MB (or expand existing databases beyond that size).

This is a limit imposed by Safari - as other people have noted, SQLite itself supports much larger databases that you can use from native apps. But webapps are limited to 50MB.

It might be useful to note that this is per database - if you really need the extra space, you can create multiple databases, although this would obviously cause a lot of hassle.

3:通过配置,要求程序在suspend后直接退出exit,类似通过删除当前的后台未运行应用

There’s a key that can be specified in your AIR app-descriptor.xml iPhone section to do this, that when set to true will inform the device that it should completely exit the application rather than suspend it (when the user hits the home button to go to another application for instance). The flag is called UIApplicationExitsOnSuspend and requires a Boolean value. The definition for this flag from the Apple docs says:

当以上的key是yes,程序会被结束,并且从内存中移开,而不是move到后台。这个key只有在ios4.0以及后续平台支持。

<iPhone>
        <InfoAdditions><![CDATA[
            <key>UIDeviceFamily</key>
            <array>
                <string>1</string>
                <string>2</string>
            </array>
            <key>UIApplicationExitsOnSuspend</key>
            <true/>
        ]]></InfoAdditions>
        <requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
所以我们看到只能使用true/false;YES/NO是不能使用的。

UIApplicationExitsOnSuspend

UIApplicationExitsOnSuspend (Boolean - iOS) specifies that the application should be terminated rather than moved to the background when it is quit. Applications linked against iOS SDK 4.0 or later can include this key and set its value to YES to prevent being automatically opted-in to background execution and application suspension. When the value of this key is YES, the application is terminated and purged from memory instead of moved to the background. If this key is not present, or is set to NO, the application moves to the background as usual.

This key is supported in iOS 4.0 and later.

在程序的默认。plist文件中;Application dose not run in background选YES,(实际后台是

<key>UIApplicationExitsOnSuspend</key>

<true/>

)这样在 OS 4.0 后的applicationWillTerminate就能存盘了。  ......applicationWillTerminate中进行后续处理。。。。。

//完成后续处理的代码,

- (void)applicationWillTerminate:(UIApplication *)application

{

   // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:....

    //当程序退出,保存数据,如果没有设置以上的key,也需要在applicationDidEnterBackground其中做同样的工作

}

原生态第支持在后他运行,及时不需要进入suspend模式

By default no, the apps are automatically suspended after being moved to the background and do not execute any code while suspended. I think you would have to do something natively around it to keep it in the background without going into suspended mode. Check out this link for more info about that:

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

Also, this is another great link I bookmarked that shows how applications enter different states on iOS that may also be useful:

http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/CoreApplication/CoreApplication.html#//apple_ref/doc/uid/TP40007072-CH3-SW1






原创粉丝点击