Fat*_*tie 3 ios parse-platform swift
注意:
以下是来自Parse的CA的一些想法:
https://www.parse.com/questions/ios-when-will-swift-for-parse-be-ready
(注意这个问题有多受欢迎 - 热门话题).希望它可以帮助某人
这是一个iOS7 Parse云代码调用...
如何在SWIFT中做到这一点?干杯
要清楚...... 你可以在SWIFT中使用"callFunctionInBackground",还是只需要调用objc类?
-(void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
int thisRow = indexPath.row;
PFUser *delFriend = [self.theFriends objectAtIndex:thisRow];
NSLog(@"you wish to delete .. %@", [delFriend fullName] );
// note, this cloud call is happily is set and forget
// there's no return either way. life's like that sometimes
[PFCloud callFunctionInBackground:@"clientRequestFriendRemove"
withParameters:@{
@"removeThisFriendId":delFriend.objectId
}
block:^(NSString *serverResult, NSError *error)
{
if (!error)
{
NSLog(@"ok, Return (string) %@", serverResult);
}
}];
[self back]; // that simple
}
Run Code Online (Sandbox Code Playgroud)
请注意,我注意到这是一个谷歌登陆页面,试图找出"如何做云代码调用"(与Swift无关).这是一个完整的,完整的示例代码,适用于iOS和Android的自定义云代码函数,在Parse.com世界中/sf/answers/1680757991/ 希望它可以帮助某人
将Objective-C .m文件添加到项目中.Xcode将询问有关创建Bridge Header文件的信息.说是的.
删除.m文件.在桥头文件中,添加import语句:
#import <Parse/Parse.h>
Run Code Online (Sandbox Code Playgroud)
另一个答案,有一个比我更好的演练:https://stackoverflow.com/a/24005242/353988
现在你可以在Swift中调用本机Parse代码,即:
import UIKit
import Foundation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
Parse.setApplicationId("appid", clientKey: "clientkey")
var obj = PFObject(className:"TestObject")
obj.setObject("bar", forKey: "foo")
obj.saveInBackgroundWithBlock ({
(succeeded: Bool!, err: NSError!) -> Void in
NSLog("Hi")
})
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2876 次 |
| 最近记录: |