如何使这个Parse.com云代码调用?

 斌哥第一次 发布于 2023-01-11 22:58

注意:

以下是来自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
    }

请注意,我注意到这是一个谷歌登陆页面,试图找出"如何做云代码调用"(与Swift无关).这是一个完整的,完整的示例代码,适用于iOS和Android的自定义云代码函数,在Parse.com世界中/sf/ask/17360801/ 希望它可以帮助某人

1 个回答
  • 将Objective-C .m文件添加到项目中.Xcode将询问有关创建Bridge Header文件的信息.说是的.

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

    #import <Parse/Parse.h>
    

    另一个答案,有一个比我更好的演练: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")
        })
    
      }
    
    }
    

    2023-01-11 23:12 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有