小编Kha*_*war的帖子

Swift数组 - 使用AnyObject类型的"Contains"

我想contains在类型的数组上使用函数AnyObject

import UIKit

var resultArray: Array<AnyObject> = Array()
resultArray.append(50)
resultArray.append(false)
resultArray.append("Test string")
let found = contains(resultArray, 50)
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Type 'AnyObject -> L' does not conform to protocol 'IntegerLiteralConvertible'
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

ios swift

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

CoreData - 更新模型类而不是创建新模型

我在iOS应用程序中使用CoreData.在创建NSManagedObject类时,我大多数时候都会遇到问题.

这就是我做的:

  1. 我在.xcdatamodeld文件中创建一个实体.
  2. 创建属性和关系.
  3. 选择Editor->Create NSManagedObject Class创建.h.m类的选项.
  4. .h.m类中,我创建了一些用于获取/保存对象的自定义方法.

到现在为止还挺好.但是在将来如果我必须更改某些属性,我会重复步骤2和3.但是这次我在步骤4中编写的所有自定义代码都会自动删除.

所以我的问题是如何更新现有的类?而不是使用Editor->Create NSManagedObject Class删除所有自定义代码的选项.

任何帮助表示赞赏.

更新:

测试了两种方法(类别和Mogernator),看起来很好.但我选择了一种纯粹的Xcode方法.我不想承担由于XCode更新而导致将来可能破坏的任何第三方的风险,或者可能导致数据迁移问题.

感谢@Tom Harrington和@Valentin Shamardin指导我:)

iphone core-data objective-c nsmanagedobject ios

5
推荐指数
2
解决办法
7768
查看次数

如何为不同的Firebase托管项目设置域及其子域

假设我的域名是mydomain.com,并且是subdomain subdomain.mydomain.com。我从哥达迪那里得到的。

我想要的是

我想在每个网站上运行不同的网站。

mydomain.com ->网站1

subdomain.mydomain.com ->网站2

我到目前为止的设置

Website 1托管在Firebase project 1默认URL 上,并可以通过默认URL访问firebase-projectid.firebaseapp.com

Website 2托管在Firebase project 2默认URL 上,并可以通过默认URL访问。

两个Firebase项目都在同一Google帐户上。

到目前为止我已经成功完成了什么

我从mydomain.com->网站1开始

通过添加由提供的TXT记录来验证域名Firebase project 1

添加了几条A记录以将域指向Firebase project 1托管。

到目前为止一切顺利,并且mydomain.com工作正常。

什么不起作用

现在,我要托管subdomain.mydomain.com->网站2 Firebase project 2

我首先添加了自定义子域subdomain.mydomain.com。Firebase已经验证了域,并直接为我提供了A记录的IP地址。我在域名注册商上添加了两个A记录。

据我了解,这些只是步骤。但是subdomain.mydomain.com无法正常工作,Firebase仍将子域的状态显示为Needs Setup

观察结果

我观察到的两件事对我来说似乎很奇怪。

  1. IP地址为这两个项目提供的火力地堡mydomain.comsubdomain.mydomain.com相同。不知道这是否正常。
  2. subdomain.mydomain.com带有A记录的内容,在选中时不会传播https://dnschecker.org/。但是,如果通过Godaddy转发选项添加了子域,则它将在几分钟内开始传播。

问题

  1. 顺便说一句,真的有可能在运行不同网站的Firebase上托管域及其子域吗?
  2. 如果是,那我还有其他步骤吗?
  3. 任何想法为什么 …

subdomain firebase firebase-hosting

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

Objective-c从URL检查文件大小而不下载

我需要从URL检查文件的大小.使用AFNetworking下载文件时,我可以完美地获得文件大小.

AFHTTPRequestOperation *operation = [client HTTPRequestOperationWithRequest:request
                                                                        success:^(AFHTTPRequestOperation *operation, id responseObject) {
                                                                            // Success Callback

                                                                        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                                                            // Failure Callback

                                                                        }];
Run Code Online (Sandbox Code Playgroud)

并在另一个块中获取文件大小

[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {

    }];
Run Code Online (Sandbox Code Playgroud)

但我需要在启动下载请求之前检查文件大小,以便我可以提示用户.我也试过另一种方法

NSURL *url = [NSURL URLWithString:@"http://lasp.colorado.edu/home/wp-content/uploads/2011/03/suncombo1.jpg"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSLog(@"original = %d", [data length]);
Run Code Online (Sandbox Code Playgroud)

但它会阻止UI,因为它会下载所有数据以计算其大小.在下载之前有没有办法检查文件大小?任何帮助表示赞赏.

objective-c ios

4
推荐指数
2
解决办法
5239
查看次数

RestKit - Lipo错误:无法在Xcode5中打开输入文件

我有一个iOS应用程序,我需要在iOS7上升级.我使用的是RestKit版本0.10.2.归档时我得到以下错误.

/Applications/Xcode 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: /Users/khawarshahzad/Library/Developer/Xcode/DerivedData/MyAPP-fcvmsuowvnqkdseskmuetssnxoww/Build/Intermediates/ArchiveIntermediates/MyAPP/IntermediateBuildFilesPath/MyAPP.build/Release-iphoneos/MyAPP.build/Objects-normal/armv7s/MyAPP (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

以前我已经按照https://github.com/RestKit/RestKit/issues/930上的说明修复了iOS6的这个错误

但现在它不适用于iOS7.以下是当前RestKit.xcodeproj架构设置的屏幕截图. 在此输入图像描述

任何建议表示赞赏.

xcode ios restkit ios7 xcode5

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

RestKit - 实体(null)不是键值"id"的键值编码兼容

尝试使用RestKit上传图像时,我遇到了一个奇怪的问题.我研究过类似的问题,但没有一个能解决我的问题.

在我的应用程序中,用户可以创建一些任务的注释

所以,我有两个设置RKEntityMappingRKObjectMapping映射,像这样:

- (RKEntityMapping *)commentsMapping {

    RKEntityMapping *commentsMapping = [RKEntityMapping mappingForEntityForName:@"DBComments" inManagedObjectStore:objectManager.managedObjectStore];
    commentsMapping.setDefaultValueForMissingAttributes = NO;
    commentsMapping.identificationAttributes = @[@"id"];
    [commentsMapping setModificationAttributeForName:@"updated_at"];

    [commentsMapping addAttributeMappingsFromDictionary:@{
                                                          @"body" : @"body",
                                                          @"created_at" : @"created_at",
                                                          @"id" : @"id",
                                                          @"parent_id" : @"parent_id",
                                                          @"send_email" : @"send_email",
                                                          @"updated_at" : @"updated_at",
                                                          @"user.id" : @"user_id",
                                                          @"user.name" : @"user_name",
                                                          }];

    [commentsMapping addRelationshipMappingWithSourceKeyPath:@"attachments" mapping:[self attachmentsMapping]];

    return commentsMapping;
}


- (RKObjectMapping *)commentsRequestMapping {
    RKObjectMapping *commentsRequestMapping = [RKObjectMapping requestMapping];
    [commentsRequestMapping addAttributeMappingsFromDictionary:@{
                                                                 @"body" : @"body",
                                                                 @"created_at" : @"created_at",
                                                                 @"id" : @"id",
                                                                 @"parent_id" …
Run Code Online (Sandbox Code Playgroud)

core-data objective-c ios restkit restkit-0.20

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

Swift零宽度空间?

如何创建NSString零宽度空间.

在Objective-C中,我曾经像这样创建:

NSString *emptyText = @"\u200B";
Run Code Online (Sandbox Code Playgroud)

如何在Swift中创建它?我试过跟随,但它没有用.

let emptyString = "\u200B"
Run Code Online (Sandbox Code Playgroud)

iphone ios swift

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

混淆Apple In App Purchase产品

我正在创建一个像Evernote iPad一样的应用笔记.我决定提供一些In App Purchase计划,原因有两个.

  1. 在应用程序中解锁更多功能.
  2. 应在指定时间段后自动更新.

现在我有一个混乱的应用程序购买类型为此选择.我对自动可再生订阅感兴趣

参观guidlines后在这里,我发现

您可以使用应用程序内购买在应用程序中销售和解锁其他功能.通常应将其他功能添加到应用程序中,并将其视为非耗材.

但非消耗品不可自动更新.

那么我应该选择哪种产品呢?

Apple是否批准通过自动续订订阅解锁应用功能?

此外,在购买计划后,用户可以使用相同的Apple ID解锁(恢复)功能的设备数量是多少?

iphone in-app-purchase ipad ios

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

Sencha touch - Ext.XTemplate 如果/否则不起作用

嗨,我是 Sencha touch 的新手。我在Ext.dataview.ListitemTpl. 这就是我设置itemTpl的方式config

itemTpl: new Ext.XTemplate(

            '<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',

            '<span class="item">',
                '<h3 class="saleName">{itemName}</h3>',
                '<span class="priceOptions">',
                '<tpl for="prices">',
                    '<span class="priceOptionReg">',
                        '<tpl if="priceOptionDesc">{priceOptionDesc}</tpl> ',
                        '<tpl if="priceOptionReg">{priceOptionReg}</tpl>  ',
                        '<tpl if="priceReg">${priceReg}</tpl>  ',
                        '<tpl if="priceRegSuffix">{priceRegSuffix}</tpl> ',
                    '</span>',
                    '<tpl if="priceSale"><span class="priceOptionSale">',
                        '<tpl if="priceSaleDesc">{priceSaleDesc}</tpl> ',
                        '<tpl if="priceOptionSale">{priceOptionSale}</tpl>  ',
                        '<tpl if="priceSale">${priceSale}</tpl>',
                        '<tpl if="priceSaleSuffix">{priceSaleSuffix}</tpl> ',
                    '</span></tpl>',
                '</tpl>',
                '</span>',
            '</span>',
            '<div class="clear"></div>'
        ),
Run Code Online (Sandbox Code Playgroud)

它运行良好并显示产品列表。但是现在我只需要更改第一条记录的 CSS 类,因为它是一个广告横幅。所以我使用以下 if 语句:

itemTpl: new Ext.XTemplate(
                '<tpl if={isBanner} === true>',
                    '<div class="myTestClass">{itemImage}</div>',

                '<tpl …
Run Code Online (Sandbox Code Playgroud)

javascript template-engine extjs sencha-touch sencha-touch-2

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

RestKit - 映射到同一实体的关系会创建一个infine循环

我需要创建一个实体与同一实体的关系.基本上它是Meetings可能有任何实体ParantMeeting.

在此输入图像描述

这就是我创造关系的方式.

- (RKEntityMapping *)meetingsMapping {

    RKEntityMapping *meetingsMapping = [RKEntityMapping mappingForEntityForName:@"DBMeetings" inManagedObjectStore:objectManager.managedObjectStore];
    meetingsMapping.setDefaultValueForMissingAttributes = NO;
    meetingsMapping.deletionPredicate = [NSPredicate predicateWithFormat:@"shouldBeDeleted = 1"];
    [meetingsMapping setModificationAttributeForName:@"updated_at"];
    meetingsMapping.identificationAttributes = @[@"id"];

    [meetingsMapping addAttributeMappingsFromDictionary:@{
                                                          @"id": @"id",
                                                          @"title": @"title",

                                                          @"start_time": @"start_time",
                                                          @"finish_time": @"finish_time",

                                                          @"lock": @"lock",
                                                          @"location": @"location",
                                                          @"sample": @"sample",

                                                          @"deleted": @"shouldBeDeleted",

                                                          @"created_at": @"created_at",
                                                          @"updated_at": @"updated_at",
                                                          @"follow_up_id": @"follow_up_id",
                                                          @"total_topics": @"total_topics",
                                                          }];

    [meetingsMapping addRelationshipMappingWithSourceKeyPath:@"tags" mapping:[self tagsMapping]];
    [meetingsMapping addRelationshipMappingWithSourceKeyPath:@"required_participants" mapping:[self contactsMapping]];
    [meetingsMapping addRelationshipMappingWithSourceKeyPath:@"optional_participants" mapping:[self contactsMapping]];
    [meetingsMapping addRelationshipMappingWithSourceKeyPath:@"readonly_participants" mapping:[self contactsMapping]];
    [meetingsMapping addRelationshipMappingWithSourceKeyPath:@"organizer" mapping:[self contactsMapping]];
    [meetingsMapping addRelationshipMappingWithSourceKeyPath:@"parent_meeting" mapping:[self …
Run Code Online (Sandbox Code Playgroud)

core-data objective-c ios restkit restkit-0.20

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

Cocos2d-x如何创建带有标题和字体的图像按钮

嗨,我正在将我的游戏从Corona SDK转换为Cocos2d-x 3.0 alpha.

我需要创建一个带有文本的图像按钮.在Corona SDK中它非常简单widget.newButton,它可以x, y, size, font, image在单个函数中使用所有等.

现在我在Cocos2d-x中找不到任何替代品.我发现的最接近的是MenuItemImage

auto closeItem = MenuItemImage::create(
                                    "blank.png",
                                    "blank-selected.png",
                                     CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));

closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , origin.y + closeItem->getContentSize().height/2));

auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 1);
Run Code Online (Sandbox Code Playgroud)

它需要imagesevent,但我不能设置titlefont它.任何人都知道如何设置标题和字体?

iphone game-engine ios cocos2d-x

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

SwiftUI | 如何覆盖像 viewWillAppear 这样的生命周期方法

在我现有的应用程序中,几乎没有 UI 配置,例如在所有视图控制器上设置自定义导航栏、设置全屏背景图像等等。为此,在viewWillAppear所有视图控制器中的基本视图控制器中进行配置并从它继承。所以配置是在子视图控制器中不做任何事情的情况下进行的

如何使用 SwiftUI 实现类似的实现?

SwiftUI在 View 上提供了onAppear()&onDisappear()方法,它是 Struct,不支持继承。如果我制作扩展方法或协议,我必须从所有视图调用方法。

任何帮助表示赞赏...

ios swift swiftui

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