如何进行此Parse.com云代码调用? [英] How to make this Parse.com cloud code call?

查看:95
本文介绍了如何进行此Parse.com云代码调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:

这是来自Parse CA的一些想法:

Here's some thoughts from CA at Parse about this:

https://www.parse .com/questions/ios-when-swift-for-parse-ready

(注意该问题的受欢迎程度-热门话题).希望对别人有帮助

(notice how popular that question is - hot topic). Hope it helps someone

这是一个iOS7解析云代码调用...

Here's an iOS7 Parse cloud code call ...

如何在SWIFT中做到这一点?欢呼

how to do this in SWIFT ? cheers

要清楚... 您可以在SWIFT中使用"callFunctionInBackground" ,还是只需要调用objc类?

To be clear ... can you use "callFunctionInBackground" in SWIFT, or do you have to just call to an objc class?

-(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
    }


注意,我注意到这是一个Google登陆页面,用于尝试找出如何进行云代码调用"(与Swift无关).这是在Parse.com世界https://stackoverflow.com/a/24010828/294884 希望它能对某人有所帮助


Note, I've noticed this is a google landing page for trying to figure out "how the heck to do cloud code calls" (unrelated to Swift). Here is a full, complete set of example code for both iOS and Android of custom cloud code functions, in the Parse.com universe https://stackoverflow.com/a/24010828/294884 Hope it helps someone

推荐答案

将Objective-C .m文件添加到您的项目中. Xcode将询问有关创建桥头文件的信息.说是.

Add an Objective-C .m file to your project. Xcode will ask about creating a Bridge Header file. Say yes.

删除.m文件.在桥头文件中,添加您的import语句:

Delete the .m file. In the bridge header file, add your import statement:

#import <Parse/Parse.h>

另一个答案,其演练比我的更好: https://stackoverflow.com/a/24005242/353988

Another answer, which has a way better walkthrough than mine: https://stackoverflow.com/a/24005242/353988

现在您可以在Swift中调用本地解析代码,即:

Now you can call native Parse code in Swift, i.e.:

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")
    })

  }

}

这篇关于如何进行此Parse.com云代码调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆