小编Sou*_*ker的帖子

如何在Core Data中编写BOOL谓词?

我有一个类型的属性,BOOL我想搜索此属性所在的所有托管对象YES.

对于字符串属性,它很简单.我创建一个这样的谓词:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"userName = %@", userName];
Run Code Online (Sandbox Code Playgroud)

但是我该如何做,如果我有一个名为selected的bool属性,我想为此做一个谓词?我可以这样做吗?

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"selected = %@", yesNumber];
Run Code Online (Sandbox Code Playgroud)

或者我是否需要其他格式说明符并且只是通过YES

iphone predicate core-data ipad ios

79
推荐指数
5
解决办法
4万
查看次数

没有设置滚动指示器?

我正在制作一个tableView,但我不想要滚动指示器,似乎无法设置将指示器设置为无.有没有其他方法可以做到这一点?

iphone uitableview uiscrollview

13
推荐指数
1
解决办法
9090
查看次数

iCloud同步失败,出现"CoreData:Ubiquity:Invalid选项:NSPersistentStoreUbiquitousContentNameKey的值不应包含句点"

CoreData:Ubiquity:无效选项:NSPersistentStoreUbiquitousContentNameKey的值不应包含句点:com.YashwantChauhan.Outis

-PFUbiquitySwitchboardEntryMetadata setUseLocalStorage :: CoreData:Ubiquity:mobile~20BF44C9-C39F-48DC-A8A1-B45FC82C7E20:com.YashwantChauhan.Outis

我遇到与iCloud同步的问题.上面这两个错误都被抛到了我的身上.我不知道是什么问题,我设置了Entitlements文件,并将Ubiquity容器设置为com.YashwantChauhan.Outis.

我使用MagicalRecord的方法启动CoreData堆栈:

[MagicalRecord setupCoreDataStackWithiCloudContainer:@"N6TU2CB323.com.YashwantChauhan.Outis" localStoreNamed:@"Model.sqlite"];
Run Code Online (Sandbox Code Playgroud)

但这甚至不应该重要,因为MagicalRecord只是简化了CoreData方法.

非常感谢.

好的更新:

- [NSFileManager URLForUbiquityContainerIdentifier:]:获取普遍容器URL时出错:Error Domain = LibrarianErrorDomain Code = 11"操作无法完成.(LibrarianErrorDomain错误11 - 客户端的com.apple不允许请求的容器标识符.developer.ubiquity-container-identifiers entitlement.)"UserInfo = 0x15e0d8a0 {NSDescription =客户端的com.apple.developer.ubiquity-container-identifiers权利不允许请求的容器标识符.}

这是我收到的最新错误消息,我意识到这与问题的初始错误不同,但事实证明旧消息是某种奇怪的错误.我通过删除Ubiquity Container标识符中的句点来尝试@Rauru Ferro的解决方案.我知道这不会起作用,因为标识符的要求是包含句点,但是当我将句点放回时,它会将上面的错误消息吐出来.这比使用句点更有意义.我们都知道我们这样做.

我还发现了这个方便的代码片段,可以通过获取它来实际检查我的Ubiquity Container标识符.有用的代码片段可以快速检查您是否有任何问题.

NSString *containerId = @"com.YashwantChauhan.Outis";
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:containerId];
NSLog(@"%@", [iCloudURL absoluteString]);
Run Code Online (Sandbox Code Playgroud)

另一个更新:从它的外观来看,这个愚蠢NSPersistentStoreUbiquitousContentNameKey should not contain periods是一团糟.如果NSPersistentStoreUbiquitousContentNameKey创建像某种文件夹(Tutorial),那么要求是没有.名称的前面,.com.YashwantChauhan.Outis但事实并非如此.我开始疯了!Entitlements文件没有问题,并且在MagicalRecord中没有提取iCloud容器ID.我开始认为这是在Xcode 5中设置iCloud的内部问题,但我当然不知道.有了这个说法,我可能会对一些微不足道的东西或其他会让其他人头痛的事情失去理智.

任何人都可以发布他们的Entitlements文件,以便我可以验证实际工作版本的样子.当然是编辑的.谢谢!

core-data ios icloud magicalrecord

9
推荐指数
1
解决办法
3622
查看次数

动态NSOutlineView数据源

所以我实现了一个PXSourceList数据源,它几乎是Apple的NSOutlineView数据源示例的副本.

这是怎么回事......

- (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(id)item; {
    if (item == nil) {
        // item is nil so it's part of the very top hierarchy.
        // return how many sections we need.
        return 2;
    }
    else {
        if ([item class] == [TSFileSystemItem class] ) {
            return [item numberOfChildren];
            // if item isn't nil and it's a TSFileSystemItem, then return it's children.
        }
        if ([item class] == [TSWorkspaceItem class]) {
            return 2; // i don't know, random items.
        } …
Run Code Online (Sandbox Code Playgroud)

cocoa datasource objective-c nsoutlineview pxsourcelist

5
推荐指数
1
解决办法
587
查看次数

在UIButton中实现切换功能

我想知道如何将切换功能添加到a UIButton,就像用户点击一个未选中的按钮一样,按钮被选中并保持选中状态,直到用户再次点击它为止,就像之前一样.

我正在考虑制作一个IBAction将其从未选中更改为选中的,我该怎么做?

继承人我试过的:

-(IBAction)toggle {

    //Toggle on implementation.

        button.selected = YES;
        button.highlighted = NO;
        button.enabled = YES;

    //Toggle off implementation.

    if (button.highlighted == YES) {

        button.selected = NO;
        button.highlighted = YES;
        button.enabled = NO;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题...

-(IBAction)toggleFav {

    if (favButton == nil) {

        UIImage *unselectedImage = [UIImage imageNamed:@"favUntapped.png"];
        UIImage *selectedImage = [UIImage imageNamed:@"favTapped.png"];
        [favButton setImage:unselectedImage forState:UIControlStateNormal];
        [favButton setImage:selectedImage forState:UIControlStateSelected];
        [favButton setFrame:CGRectMake(0, 0, 40, 40)];
    }       

    if([favButton isSelected]){

        //Add to menu.
        [favButton setSelected:NO];
    } else { …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uibutton uiimageview ios

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

在iOS中查找字符串中的标签

我不知道应该怎么做,我尝试过使用如下代码:

NSString *stringToFind = @"Hi";
NSString *fullString = @"Hi Objective C!";
NSRange range = [fullString rangeOfString :stringToFind];
if (range.location != NSNotFound)
{
    NSLog(@"I found something.");
}
Run Code Online (Sandbox Code Playgroud)

但它不符合我的需要,我想搜索一个像#customstring(#表示标签)的字符串,其中标签由用户指定,所以他们输入这样的东西Something #hello #world,我想要做的是搜索所有的#和字符串附加到它并保存在某处.

编辑:创建的标记字符串,我将其保存在plist中,但是当我保存它时,它只保存一个标记,因为我只是将字符串指定为标记.像这样:

[db addNewItem:label tagString:tag];
Run Code Online (Sandbox Code Playgroud)

我需要创建所有标签.例如在我的日志中:

我记录了tag,这就出现了#tag,我tag再次使用这样的两个标签登录Something #hello #world我得到两个这样的标签:#hello&#world每个单独的日志.

我想要的结果是:

#hello, #world然后将其存储在一个字符串中并保存到我的DB.

regex string ios

0
推荐指数
1
解决办法
994
查看次数