我使用NSFetchedResultsController来显示一堆对象,这些对象使用日期进行分区.在全新安装中,它完全正常工作,对象显示在表格视图中.然而,似乎当应用程序重新启动时,我遇到了崩溃.我在初始化NSFetchedResultsController时指定了一个缓存,当我不这样做时,它完美地工作.
以下是我创建NSFetchedResultsController的方法:
- (NSFetchedResultsController *)results {
// If we are not nil, stop here
if (results != nil)
return results;
// Create the fetch request, entity and sort descriptors
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:self.managedObjectContext];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"utc_start" ascending:YES];
NSArray *descriptors = [[NSArray alloc] initWithObjects:descriptor, nil];
// Set properties on the fetch
[fetch setEntity:entity];
[fetch setSortDescriptors:descriptors];
// Create a fresh fetched results controller
NSFetchedResultsController *fetched = [[NSFetchedResultsController alloc] initWithFetchRequest:fetch managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"day" …Run Code Online (Sandbox Code Playgroud) 我有一些代码我想只在最新的iPhone SDK(3.0)上执行,但我似乎无法找到一种方法来定位3.0并忽略2.2.1等.有一个ifdef语句,但它似乎覆盖了整个iPhone:
#if TARGET_OS_IPHONE
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
我试图在一些当前的UIImage(白色)上添加黑色覆盖.我一直在尝试使用以下代码:
[[UIColor blackColor] set];
[image drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeOverlay alpha:1.0];
Run Code Online (Sandbox Code Playgroud)
但它不起作用,而且我很确定套装不应该在那里.
我在我的iPhone应用程序中使用了AddressBook.framework,我想在Contacts.app中按照共享功能的方式复制一些内容.这基本上是将特定联系人vCard附加到电子邮件中.据我所知,文档中没有提到生成vCard的内容.
这是自己生成一个的情况吗?或者有什么可以帮助我吗?
我有一个iPhone应用程序,它使用AddressBook.framework并使用Core Data来存储这些联系人.为了确保在更新地址簿时更新我自己的数据库(无论是通过MobileMe还是在我自己的应用程序中进行编辑),我正在订阅有关通讯簿何时更新的通知.我在启动时调用它:
ABAddressBookRef book = ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(book, addressBookChanged, self);
Run Code Online (Sandbox Code Playgroud)
哪个(据说)在任何编辑时调用它.我有一个允许编辑的ABPersonViewController,而且似乎永远不会调用addressBookChanged.
void addressBookChanged(ABAddressBookRef reference, CFDictionaryRef dictionary, void *context) {
// The contacts controller we need to call
ContactsController *contacts = (ContactsController *)context;
// Sync with the Address Book
[contacts synchronizeWithAddressBook:reference];
}
Run Code Online (Sandbox Code Playgroud)
它有什么理由不被称为?
我正在尝试生成'包含'模板html文件的php文件,如下所示:
$page = htmlspecialchars("Hello! <?php include("template.html"); ?>");
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,我得到:
解析错误:语法错误,第15行/home/oliver/web/postmanapp.com/public/core.php中的意外T_STRING
我很确定我需要逃避PHP代码,只是不确定如何.
iphone ×5
addressbook ×2
objective-c ×2
cocoa ×1
cocoa-touch ×1
core-data ×1
php ×1
uiimage ×1
vcf-vcard ×1