小编Orb*_*sii的帖子

Google自定义搜索:iOS中的403错误

谷歌自定义搜索从我的iPhone 7.1应用程序返回此403错误.这是在模拟器中运行时的响应:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
 }
}
Run Code Online (Sandbox Code Playgroud)

下面的步骤有缺陷吗?我想建立一个针对iOS应用程序的工作CSE设置过程.每一步的屏幕截图都有望帮助而不是混淆!

  1. 通过https://www.google.com/cse/创建自定义搜索引擎(CSE)

  2. 从设置 - >基础知识,获取搜索引擎ID. CSE搜索引擎ID

  3. 通过https://developers.google.com/apis-explorer/#p/customsearch/v1/search.cse.list测试CSE

    • 在步骤2中将"q"设置为搜索引擎ID的任何测试查询字词("foo bar")和"cx".
    • 按"执行"并接收搜索结果.他们工作.Google还提供了此网址,我们将在第8步中在Xcode中重复使用该网址. Google API Explorer测试结果
  4. 要获得ID和计费目的的密钥,请通过以下网址创建新项目:https://console.developers.google.com/

  5. 在API&auth - > API - >启用"自定义搜索API".没有启用其他API. 开发者控制台API

  6. 在API&auth - >凭据 - >创建新的iOS密钥. 开发者控制台凭据 注意:我还尝试了浏览器密钥,搜索结果返回"错误400:无效值".我回到iOS键,因为我在iOS上,错误似乎不那么严重.

  7. 从Xcode添加此密钥标识符. …

search-engine google-api ios google-custom-search

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

核心数据:EXC_BAD_ACCESS访问关系

我在一个简单的Core Data项目中崩溃了.

我用Core Data创建了一个新的空iPhone项目.两个实体被添加到数据模型中,它们之间具有一对一的反向关系.两者都有自动生成的NSManagedObject子类.实体名称和类都设置在两者上.

DBMove
  attribute: moveValue:Integer16
  relationship: newPosition -> DBPosition (inverse: move)

DBPosition 
  attribute: positionValue:Integer16
  relationship: move -> DBMove (inverse: newPosition)
Run Code Online (Sandbox Code Playgroud)

有一个自定义视图控制器,可以创建DBMove和DBPosition.然后它设置它们之间的反比关系并保存它.从app delegate中检索托管对象上下文; 我认为这是安全的,因为[NSThread isMultiThreaded]返回false.

- (void)newEntries
{
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     NSManagedObjectContext *context = appDelegate.managedObjectContext;

     DBPosition *newPos = [NSEntityDescription
                      insertNewObjectForEntityForName:@"DBPosition"
                      inManagedObjectContext:context];
     newPos.positionValue = [NSNumber numberWithInt:5];

     DBMove *newMove = [NSEntityDescription
                   insertNewObjectForEntityForName:@"DBMove"
                   inManagedObjectContext:context];
     newMove.moveValue = [NSNumber numberWithInt:2];

     newPos.move = newMove;

     NSError *error;
     if (![context save:&error]) {
         NSLog(@"Save error: %@", [error localizedDescription]);
    }
}
Run Code Online (Sandbox Code Playgroud)

视图控制器然后提取所有DBMoves.他们的Integer16属性按预期输出. [编辑]访问关系会导致main :: @ …

core-data objective-c nsmanagedobject ios

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