相关疑难解决方法(0)

核心数据NSPredicate检查BOOL值

我目前在从db中提取所有数据时遇到问题,即1参数为TRUE.

我正在使用NSPredicate,下面是一个示例代码

NSManagedObjectContext *context = managedObjectContext_;

if (!context) {
    // Handle the error.
    NSLog(@"ERROR CONTEXT IS NIL");
}

NSEntityDescription *entity = [NSEntityDescription entityForName:@"tblcontent" inManagedObjectContext:managedObjectContext_];

NSFetchRequest *request = [[NSFetchRequest alloc] init];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"bookmarked == YES"];

[request setPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)

我尝试将predicatewithformat设置为几乎所有内容,但它仍然没有拉出具有YES值的书签.

我甚至试过(@"bookmarked == %d",YES)但没有运气.我不想得到整个数组,然后通过做if(object.bookmarked == YES)..... blabla 手动过滤它.

我真的很感激一些帮助.

非常感谢.

database iphone core-data objective-c nspredicate

32
推荐指数
6
解决办法
3万
查看次数

登录时应用程序崩溃(xcode 9.3)EXC_BAD_ACCESS(代码= 1,地址= 0x1)

我在9.3更新中遇到此崩溃,在9.2上一切正常.它能是什么?通过任何来源登录时出现错误(登录通行证,VK,谷歌)

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {

var window: UIWindow?

private let settingsManager = SettingsManager.manager

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

//  Googole Map
    GMSServices.provideAPIKey("-k")

    UINavigationBar.appearance().tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
    UINavigationBar.appearance().barTintColor = #colorLiteral(red: 0.2069905996, green: 0.2386507988, blue: 0.3337202668, alpha: 1)

    UITabBar.appearance().tintColor = #colorLiteral(red: 0.2069905996, green: 0.2386507988, blue: 0.3337202668, alpha: 1)

    let barFont = UIFont.systemFont(ofSize: 20)
    UINavigationBar.appearance().titleTextAttributes =  [NSForegroundColorAttributeName: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), NSFontAttributeName: barFont]


    if settingsManager.isFirstStartApp …
Run Code Online (Sandbox Code Playgroud)

swift xcode9.3

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