My application use UIImagePickerController for taking photos. It works well but one serious problem — memory crashes. The application crashes always after taking several photos, mostly around 4-6. Looked through the debug information, I found it occurs memory warning message frequently and crashes after entering didReceivedMemoryWaning twice. Viewing the memory use in Instrument (which is the performance tool integrated in xcode) , the memory in use increase about 18 MB, it’s really horrible. After a long time research, I got some solutions to improve it.
[阅读全文]Tags: iPhone, memory leak, UIImagePickerController
最近在写一个iPhone上的程序, 其中用到了google maps, 最简单的做法是在程序中嵌入一个UIWebView然后加载一个网页,在网页中写上一段javascript并包含google maps 地图对象即可, 这样的做法简单但有很大的弊端。 主要是效率以及稳定性的问题, UIWebView似乎是缓存了很多文件, 而又没有开放的接口用于释放清除这些缓存内容,这就导致程序可使用内存越来越小,直至崩溃,尤其是如果要同时使用UIImagePickerController那就更严重。 所以只要自己写maps 显示模块, 基本思路是给定一个中心点 地理坐标也就是经纬度, 然后计算所在图块(Tile Maps)的序号,根据当前放大倍数构建URL 然后在使用多线程下载小图块后显示
[阅读全文]Tags: google, google map, iPhone
Objective-C2.0 号称可以支持Garbage Collection了, 也就是垃圾回收, 但是我还没在xcode以及文档中找到相关的用法,也懒得去查了。 关于garbage collection的内容也没啥可说的, 想说说这几天遇到的无GC情况下的几个内存相关问题。
[阅读全文]Objective-C中的属性
在C++中,类可以有自己的成员变量, 一般公有成员变量可以直接通过类对象访问或修改, 保护成员变量和私有成员变量通过相应的函数来存取,比如
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | class CPerson { public: int gender; protected: int age; public: int GetAge(){return age;} void SetAge( int newValue){ age = newAge;} }; void test(){ CPerson person; person.gender = 0; person.SetAge(20); printf("性别:%d",person.GetAge() ); printf("年龄:%d",person.gender); } |
Tags: Apple, cocoa, iPhone, Objective-C, XCode