小编And*_*son的帖子

iPhone编程:我可以在应用程序的文档目录(根文件夹)中存储多少数据?

我问的原因是我的应用程序允许用户缓存地图图块.有谁知道我可以让他们存储多少数据的真实上限?

iphone objective-c

4
推荐指数
1
解决办法
642
查看次数

使用Common Code构建两个iPhone应用程序

我有一个iPhone应用程序,我正在采取该应用程序的一些功能,并创建一个新的应用程序.

从公共代码库构建两个应用程序的适当方法是什么?

iphone cocoa-touch objective-c

4
推荐指数
1
解决办法
452
查看次数

在Objective C中序列化对象

当用户通过我的应用程序上传内容时,我创建了一个ASIFormDataRequest对象来进行POST.

当用户离线时,我想写一个ASIFormDataRequest对象来存档并稍后发送.

是否有内置的方法来在Objective C中序列化这样的对象,或者我是否必须从头开始编写代码?

iphone cocoa-touch objective-c

4
推荐指数
1
解决办法
9146
查看次数

这个巨大的if语句感觉很难......你会如何在Objective C中做到这一点

for (NSString *metarComponent in self.readingComponents) {
    if ( [metarComponent hasPrefix:@"+"]
         || [metarComponent hasPrefix:@"-"]
         || [metarComponent hasPrefix:@"VC"]
         || [metarComponent hasPrefix:@"MI"]
         || [metarComponent hasPrefix:@"PR"])
         || [metarComponent hasPrefix:@"BC"])
         || [metarComponent hasPrefix:@"DR"])
         || [metarComponent hasPrefix:@"BL"])
         || [metarComponent hasPrefix:@"SH"])
         || [metarComponent hasPrefix:@"TS"])
         || [metarComponent hasPrefix:@"PZ"])
         || [metarComponent hasSuffix:@"DZ"])
         || [metarComponent hasSuffix:@"RA"])
         || [metarComponent hasSuffix:@"SN"])
         || [metarComponent hasSuffix:@"SG"])
         || [metarComponent hasSuffix:@"IC"])
         || [metarComponent hasSuffix:@"PL"])
         || [metarComponent hasSuffix:@"GR"])
         || [metarComponent hasSuffix:@"GS"])
         || [metarComponent hasSuffix:@"UP"])
         || [metarComponent hasSuffix:@"BR"])
         || [metarComponent hasSuffix:@"FG"])
         || [metarComponent hasSuffix:@"FU"])
         || [metarComponent hasSuffix:@"VA"])
         || …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c

4
推荐指数
1
解决办法
211
查看次数

这是我应该提交给Apple的错误,还是这种预期的行为?

使用CoreData时,以下多列索引谓词非常慢 - 26,000条记录需要大约2秒钟.

请注意,这两列都已编制索引,并且我有目的地使用>和<=而不是beginwith进行查询,以使其快速:

NSPredicate *predicate = [NSPredicate predicateWithFormat:
  @"airportNameUppercase >= %@ AND airportNameUppercase < %@ \
        OR cityUppercase >= %@ AND cityUppercase < %@ \
    upperText, upperTextIncremented,
    upperText, upperTextIncremented];
Run Code Online (Sandbox Code Playgroud)

但是,如果我运行两个单独的fetchRequests,每列一个,然后我合并结果,那么每个fetchRequest只需1-2个百分之一秒,并且合并列表(已排序)大约需要1/10第二.

这是CoreData如何处理多个索引的错误,还是这个预期的行为?以下是我的完整优化代码,它运行速度非常快:

NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init]autorelease];
[fetchRequest setFetchBatchSize:15]; 

// looking up a list of Airports
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Airport" 
                                          inManagedObjectContext:context];
[fetchRequest setEntity:entity];    

// sort by uppercase name
NSSortDescriptor *nameSortDescriptor = [[[NSSortDescriptor alloc] 
           initWithKey:@"airportNameUppercase" 
             ascending:YES 
              selector:@selector(compare:)] autorelease];
NSArray *sortDescriptors = [[[NSArray alloc] initWithObjects:nameSortDescriptor, nil]autorelease];
[fetchRequest setSortDescriptors:sortDescriptors];

// use …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch core-data objective-c

4
推荐指数
1
解决办法
481
查看次数

我的iPad应用程序可以导致设备重启吗?

我有一个iPad应用程序,它有一个下载大量地图文件的过程(一些数据和几万个文件).

在我最近的测试版本中,设备有时会在下载过程中重新启动(下载可能需要几个小时).

当应用重新启动时,它不会留下崩溃报告.我们在运行4.3.3的iPad 1和iPad 2上都观察到了这种行为.

我唯一能想到的是我们将最大并发线程数从4增加到20来进行这些下载.

iphone cocoa-touch objective-c ipad

4
推荐指数
1
解决办法
1130
查看次数

如何将视图控制器设置为两个事物的委托(例如LocationManager和Accelerometer)?

如果我的问题标题看起来根本不知情,我很抱歉.让我解释一下我想做什么.

我定义了以下UIViewController子类,它触发了LocationManager,并有一个开始录制按钮来保存GPS轨道.

现在我想启动加速度计并允许用户记录它.

我的ViewController子类是LocationManager委托,那么我应该为Accelerometer委托使用什么?我可以使用相同的视图,还是需要定义子视图?

这是我的UIViewController子类的接口:

@interface RootViewController : UIViewController <CLLocationManagerDelegate> {
    NSMutableArray *eventsArray;
    NSManagedObjectContext *managedObjectContext;
    CLLocationManager *locationManager;
    BOOL recording;
    UILabel *pointLabel;
    UIButton *startStop;
}

-(void)toggleButton;
Run Code Online (Sandbox Code Playgroud)

如果需要,我可以发布更多代码,但我认为这一切都适用.感谢您的帮助,我刚刚进入iPhone开发阶段,如果有的话,我的专业知识在于无指针编程语言:)

iphone cocoa-touch accelerometer core-location

3
推荐指数
1
解决办法
4127
查看次数

为什么这个C风格的代码比这个obj-C风格的代码慢10倍?

// obj C版本,有些 - 在18,000次迭代中不到一秒

for (NSString* coordStr in splitPoints) {

  char *buf = [coordStr UTF8String];
  sscanf(buf, "%f,%f,", &routePoints[i].latitude, &routePoints[i].longitude);

  i++;

}
Run Code Online (Sandbox Code Playgroud)

// C版 - 在18,000次迭代中超过13秒

for (i = 0; buf != NULL; buf = strchr(buf,'['), ++i) {

  buf += sizeof(char);
  sscanf(buf, "%f,%f,", &routePoints[i].latitude, &routePoints[i].longitude);

}
Run Code Online (Sandbox Code Playgroud)

作为一个推论问题,有没有办法让这个循环更快?

另见这个问题:另一种速度提升可能吗?

c iphone cocoa-touch objective-c

3
推荐指数
1
解决办法
523
查看次数

如何禁用XCode 4中某些文件类型的索引/搜索?

由于某种原因,我的XCode项目中有一些令人讨厌的JSON文件.当我进行搜索时,他们有时会挂断这些文件.

有没有办法阻止XCode4索引某些文件类型或文件?

iphone xcode ipad

3
推荐指数
2
解决办法
642
查看次数

在XCode中存档不会产生任何存档

我试图为adhoc发布和发布构建我的应用程序,无论哪种方式,归档都没有显示在Organizer中.构建成功,app和dsym文件按预期显示,但没有档案 - Organizer说"No Archives".

其他说明:

1)我认为它与"设置"中的SKIP_INSTALL属性无关.几个月前我有这个问题,并纠正了它.我还经历了我的构建设置并验证了SKIP_INSTALL再次为静态库设置为No,只是为了确保 - 存档不会出现在xcode4管理器中

2)我可以构建调试并运行应用程序就好了.

3)我在这个iMac上从几个用户帐户构建应用程序,而其他用户帐户可以为其他应用程序生成存档.

我试过搜索,但我被卡住了.我想知道是否应该尝试重新安装XCode.

iphone xcode ipad ios

3
推荐指数
1
解决办法
7321
查看次数