对象未保存在 Parse-Server 上
Object not saving on Parse-Server
我刚刚在 Parse-Server (Heroku/MLab) 上设置了一个应用程序以与 iOS 应用程序(在 objective C 中)一起使用。
参考我之前的几次此类经历,我觉得应该是可以的。但是当我尝试将对象从我的 iOS 应用程序保存到 Parse-Server 时,它失败了。
这里是初始化代码,在AppDelegate.m:
[Parse initializeWithConfiguration:
[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = @"AAAABBBCCCCXXXXYYYY333344445555";
configuration.clientKey = @"9999999888888887777777wwwwwwHHHHHHzzzzZZZ";
configuration.localDatastoreEnabled = @"https://myownapp.herokuapp.com/parse";
}]];
这是我用来在 iOS 应用程序中保存对象的代码:
PFObject *myObject = [PFObject objectWithClassName:@"MyCollectionName"];
// name and membersString are NSString objects previously defined.
myObject[@"name"] = name;
myObject[@"members"] = membersString;
[myObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if (succeeded) {
NSLog(@"all is working fine!");
} else {
NSLog(@"Error:\n%@",error);
}
}];
这是我在 Xcode 调试控制台中得到的错误:
Error Domain=Parse Code=100 "A server with the specified hostname could not be found."
UserInfo={code=100, error=A server with the specified hostname could not be found.,
NSLocalizedDescription=A server with the specified hostname could not be found.,
temporary=1, originalError=Error Domain=NSURLErrorDomain
Code=-1003 "A server with the specified hostname could not be found."
UserInfo={NSUnderlyingError=0x1c0844140 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)"
UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}},
NSErrorFailingURLStringKey=https://api.parse.com/1/classes/MyCollectionName,
NSErrorFailingURLKey=https://api.parse.com/1/classes/MyCollectionName,
_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8,
NSLocalizedDescription=A server with the specified hostname could not be found.},
NSUnderlyingError=0x1c0848b20 {Error Domain=NSURLErrorDomain
Code=-1003 "A server with the specified hostname could not be found."
UserInfo={NSUnderlyingError=0x1c0844140 {Error Domain=kCFErrorDomainCFNetwork
Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}},
NSErrorFailingURLStringKey=https://api.parse.com/1/classes/MyCollectionName,
NSErrorFailingURLKey=https://api.parse.com/1/classes/MyCollectionName, _kCFStreamErrorDomainKey=12,
_kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}}}
我已经为我的服务器设置了一个正确的名称:https://myownapp.herokuapp.com/。
我不太明白为什么我看到:https://api.parse.com出现在错误信息中。
这可能是哪里出了问题?但我真的不知道该怎么做才能改变它。
我想我已经在应用程序端和服务器端完成了所有必要的工作;但我显然遗漏了一些东西。
如果有人对解决方案有任何想法,请告诉我。将不胜感激。
您可能需要正确初始化 SDK。
configuration.localDatastoreEnabled = @"https://myownapp.herokuapp.com/parse";
这应该是:
configuration.server = @"https://myownapp.herokuapp.com/parse";
configuration.localDatastoreEnabled = true;
我刚刚在 Parse-Server (Heroku/MLab) 上设置了一个应用程序以与 iOS 应用程序(在 objective C 中)一起使用。 参考我之前的几次此类经历,我觉得应该是可以的。但是当我尝试将对象从我的 iOS 应用程序保存到 Parse-Server 时,它失败了。
这里是初始化代码,在AppDelegate.m:
[Parse initializeWithConfiguration:
[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = @"AAAABBBCCCCXXXXYYYY333344445555";
configuration.clientKey = @"9999999888888887777777wwwwwwHHHHHHzzzzZZZ";
configuration.localDatastoreEnabled = @"https://myownapp.herokuapp.com/parse";
}]];
这是我用来在 iOS 应用程序中保存对象的代码:
PFObject *myObject = [PFObject objectWithClassName:@"MyCollectionName"];
// name and membersString are NSString objects previously defined.
myObject[@"name"] = name;
myObject[@"members"] = membersString;
[myObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if (succeeded) {
NSLog(@"all is working fine!");
} else {
NSLog(@"Error:\n%@",error);
}
}];
这是我在 Xcode 调试控制台中得到的错误:
Error Domain=Parse Code=100 "A server with the specified hostname could not be found."
UserInfo={code=100, error=A server with the specified hostname could not be found.,
NSLocalizedDescription=A server with the specified hostname could not be found.,
temporary=1, originalError=Error Domain=NSURLErrorDomain
Code=-1003 "A server with the specified hostname could not be found."
UserInfo={NSUnderlyingError=0x1c0844140 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)"
UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}},
NSErrorFailingURLStringKey=https://api.parse.com/1/classes/MyCollectionName,
NSErrorFailingURLKey=https://api.parse.com/1/classes/MyCollectionName,
_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8,
NSLocalizedDescription=A server with the specified hostname could not be found.},
NSUnderlyingError=0x1c0848b20 {Error Domain=NSURLErrorDomain
Code=-1003 "A server with the specified hostname could not be found."
UserInfo={NSUnderlyingError=0x1c0844140 {Error Domain=kCFErrorDomainCFNetwork
Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}},
NSErrorFailingURLStringKey=https://api.parse.com/1/classes/MyCollectionName,
NSErrorFailingURLKey=https://api.parse.com/1/classes/MyCollectionName, _kCFStreamErrorDomainKey=12,
_kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}}}
我已经为我的服务器设置了一个正确的名称:https://myownapp.herokuapp.com/。
我不太明白为什么我看到:https://api.parse.com出现在错误信息中。 这可能是哪里出了问题?但我真的不知道该怎么做才能改变它。 我想我已经在应用程序端和服务器端完成了所有必要的工作;但我显然遗漏了一些东西。
如果有人对解决方案有任何想法,请告诉我。将不胜感激。
您可能需要正确初始化 SDK。
configuration.localDatastoreEnabled = @"https://myownapp.herokuapp.com/parse";
这应该是:
configuration.server = @"https://myownapp.herokuapp.com/parse";
configuration.localDatastoreEnabled = true;