我在让这个东西工作时遇到了可怕的事情。我花了两天时间阅读 Salesforce 网站上的文档、分布式 SDK 中的示例代码,而且我的头通常都在碰壁。
最令人沮丧的部分是我认为我只是错过了登录屏幕,但我找不到任何可以告诉我如何制作的东西。据我所知,它只是一个指向 SF 登录页面的 UIWebView。
到目前为止,这是我能够弄清楚的:
- 将 SDK 添加到我的项目(SalesforceSDK、SalesforceOAuth、RestKit)并链接到Git 自述文件中提到的所有库。
- 包含
"SFRestAPI.h"
在我用来从服务器发送和接收数据的服务器通信类中。 使用随 SDK 分发的 XCode 模板中的代码调用 SFRestRequest:
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForQuery:@"SELECT Name FROM User LIMIT 10"]; [[SFRestAPI sharedInstance] send:request delegate:self];
添加了委托方法:
#pragma mark - Salesforce REST API delegate methods
- (void)request:(SFRestRequest *)request didLoadResponse:(id)jsonResponse
{
NSLog(@"%@", jsonResponse);
}
- (void)request:(SFRestRequest *)request didFailLoadWithError:(NSError*)error
{
NSLog(@"%@", error);
}
- (void)requestDidCancelLoad:(SFRestRequest *)request
{
NSLog(@"%@", request);
}
- (void)requestDidTimeout:(SFRestRequest *)request
{
NSLog(@"%@", request);
}
5. 在控制台看到这个:
`2012-09-11 10:23:44.128 ClientApp[39697:c07] SFRestAPI::send: <SFRestRequest 0xd4a9cb0
endpoint: /services/data
method: GET
path: /v23.0/query
queryParams: {
"q" : "SELECT Name FROM User LIMIT 10"
}`
没有调用 SFRestRequest 的委托方法。
这是没有用的:
使我的应用程序委托 SFNativeRestAppDelegate 的子类
这产生了大约 12 个重复符号错误:
duplicate symbol _OBJC_CLASS_$_SFNativeRestAppDelegate in:
/Volumes/Wallace/Users/gromitt/Library/Developer/Xcode/DerivedData/ClientApp-bpccblcllzkzvudxtwutuqliagld/Build/Intermediates/ClientApp.build/Debug-iphonesimulator/ClientApp.build/Objects-normal/i386/SFNativeRestAppDelegate.o
/Volumes/Wallace/Users/gromitt/Documents/Out to Lunch/ iOS Apps/ClientApp/ClientApp/dependencies/SalesforceSDK/libSalesforceSDK.a(SFNativeRestAppDelegate.o)
duplicate symbol _OBJC_IVAR_$_SFNativeRestAppDelegate._authViewController in:
/Volumes/Wallace/Users/gromitt/Library/Developer/Xcode/DerivedData/ClientApp-bpccblcllzkzvudxtwutuqliagld/Build/Intermediates/ClientApp.build/Debug-iphonesimulator/ClientApp.build/Objects-normal/i386/SFNativeRestAppDelegate.o
/Volumes/Wallace/Users/gromitt/Documents/Out to Lunch/ iOS Apps/ClientApp/ClientApp/dependencies/SalesforceSDK/libSalesforceSDK.a(SFNativeRestAppDelegate.o)
duplicate symbol _OBJC_IVAR_$_SFNativeRestAppDelegate._viewController in:
/Volumes/Wallace/Users/gromitt/Library/Developer/Xcode/DerivedData/ClientApp-bpccblcllzkzvudxtwutuqliagld/Build/Intermediates/ClientApp.build/Debug-iphonesimulator/ClientApp.build/Objects-normal/i386/SFNativeRestAppDelegate.o
/Volumes/Wallace/Users/gromitt/Documents/Out to Lunch/ iOS Apps/ClientApp/ClientApp/dependencies/SalesforceSDK/libSalesforceSDK.a(SFNativeRestAppDelegate.o)
duplicate symbol _OBJC_IVAR_$_SFNativeRestAppDelegate._window in:
/Volumes/Wallace/Users/gromitt/Library/Developer/Xcode/DerivedData/ClientApp-bpccblcllzkzvudxtwutuqliagld/Build/Intermediates/ClientApp.build/Debug-iphonesimulator/ClientApp.build/Objects-normal/i386/SFNativeRestAppDelegate.o
/Volumes/Wallace/Users/gromitt/Documents/Out to Lunch/ iOS Apps/ClientApp/ClientApp/dependencies/SalesforceSDK/libSalesforceSDK.a(SFNativeRestAppDelegate.o)
duplicate symbol _OBJC_METACLASS_$_SFNativeRestAppDelegate in:
/Volumes/Wallace/Users/gromitt/Library/Developer/Xcode/DerivedData/ClientApp-bpccblcllzkzvudxtwutuqliagld/Build/Intermediates/ClientApp.build/Debug-iphonesimulator/ClientApp.build/Objects-normal/i386/SFNativeRestAppDelegate.o
/Volumes/Wallace/Users/gromitt/Documents/Out to Lunch/ iOS Apps/ClientApp/ClientApp/dependencies/SalesforceSDK/libSalesforceSDK.a(SFNativeRestAppDelegate.o)
duplicate symbol _kDefaultLoginHost in:
/Volumes/Wallace/Users/gromitt/Library/Developer/Xcode/DerivedData/ClientApp-bpccblcllzkzvudxtwutuqliagld/Build/Intermediates/ClientApp.build/Debug-iphonesimulator/ClientApp.build/Objects-normal/i386/SFNativeRestAppDelegate.o
/Volumes/Wallace/Users/gromitt/Documents/Out to Lunch/ iOS Apps/ClientApp/ClientApp/dependencies/SalesforceSDK/libSalesforceSDK.a(SFAccountManager.o)
ld: 6 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
任何帮助表示赞赏。提前致谢。