我基本上是在尝试使用String并在php中执行以下操作:
$signature= base64_encode(hash_hmac('sha1', $data, $secretKey, true));
Run Code Online (Sandbox Code Playgroud)
但是,在Swift中进行操作 ...我看到很多关于其他人试图使用CommonCrypto进行操作的帖子,但是该模块似乎没有安装。
所以确实有3个问题:
我当前的代码如下所示:
var authString:String = "PUT\nTEST=BLAH\nTEST2=BLAHBLAHBLAH"
let hmacResult:String = authString.sha1()
...
extension String {
func sha1() -> String {
//Do Something...
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 swift 项目,我在项目中导入了一个单例、objective-c 编码的类。
我尝试导入 productname_swift.h 文件,但没有成功。
我如何访问该单例类中的 swift 类?
我有一个iPhone应用程序并添加了WatchKitExtension.从iPhone应用程序我想传递String给WatchApp,它应该改变Watch上的图像.
MMWormhole.m&.h.它们是用Obj-C编写的,因此Xcode会自动为它们桥接它们.在GitHub的教程中,它说我必须用以下内容初始化虫洞:
self.wormhole = [[MMWormhole alloc] initWithApplicationGroupIdentifier:@"group.com.mutualmobile.wormhole"
optionalDirectory:@"wormhole"];
Run Code Online (Sandbox Code Playgroud)
...并使用以下方式发送消息:
[self.wormhole passMessageObject:@{@"titleString" : title}
identifier:@"messageIdentifier"];
Run Code Online (Sandbox Code Playgroud)
但我实际上不知道在哪里放,我在我的iPhone应用程序和 WatchExtension中使用Swift .
有人可以帮助我吗?
我试图在Swift项目中使用SDWebImage.我将SDWebImage库文件夹拖放到我的Swift项目中,并按名称listApp-Bridging-Header.h创建了一个桥接头.
然后我将头文件导入到我的Swift文件中; 像这样进口
import UIImageView+WebCache.h
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell : TableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as! TableViewCell
let strTitle : NSString = arrDict[indexPath.row].valueForKey("clip_name") as! NSString
cell.clipName.text = strTitle as String
cell.videoImage sd_setImageWithURL=NSURL URLWithString,[NSString stringWithFormat:@"%@%@",K_Server_imageurl,[record valueForKey:@"clip_image_path"]];
return cell
}
Run Code Online (Sandbox Code Playgroud)
它给了我一个错误说明add ; before +如何将上面的文件正确导入我的Swift项目?
我被要求在我的 Swift 项目中使用 Objective-C 框架。
但我不知道如何实现这一点。
我添加了这个文件:
Objective-CBridgingHeader.h
Run Code Online (Sandbox Code Playgroud)
我在这个文件中放入了:
#ifndef Objective_CBridgingHeader_h
#define Objective_CBridgingHeader_h
#import <FMShop/FMShop.h>
#endif /* Objective_CBridgingHeader_h */
Run Code Online (Sandbox Code Playgroud)
现在我期望能够:
Import FMShop
Run Code Online (Sandbox Code Playgroud)
并使用 Swift 代码访问该框架。然而当我尝试
Import FMShop
Run Code Online (Sandbox Code Playgroud)
我的项目不再编译并声称存在:“没有这样的模块‘FMShop’”
我在这里缺少什么?
我的基础 SDK 是 iOS 8.0,我使用的是 Xcode 7.3.1
这就是我的项目的样子:
注意:
以下是来自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]; // …Run Code Online (Sandbox Code Playgroud) 我已经导入了所有需要的框架,但从那时起我就不知道该怎么做了(我是Swift的新手,而且没有任何关于Objective C的内容).解析文档不在Swift中,那么有人可以给我一个起点吗?
我已经初始化了我的视图控制器(当我运行应用程序时没有出现,我只是得到一个黑屏;但基于这个视频,我应该看到一个表:https://parse.com/tutorials/parse-查询表)
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//Link to Parse
Parse.setApplicationId("...", clientKey: "...")
var controller:PFQueryTableViewController = PFQueryTableViewController(className: "test1")
self.window?.rootViewController = controller
self.window?.makeKeyAndVisible()
return true
Run Code Online (Sandbox Code Playgroud) 我有一个Objective-C类,如下所示:
@interface CustomObjectHavingData : NSObject
@property (nonatomic, strong) NSData *objWithData;
- (instancetype)initWithObjHavingData;
@end
Run Code Online (Sandbox Code Playgroud)
和这样的实现
@implementation CustomObjectHavingData
- (instancetype)initWithObjHavingData{
if (self = [super init]) {
NSString *str = @"This is simple string.";
self.objWithData = [str dataUsingEncoding:NSUTF8StringEncoding];
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
现在我想在Swift中调用这个initWithObjHavingData
var objData = CustomObjectHavingData()
Run Code Online (Sandbox Code Playgroud)
这给我的回报是零.请帮助我在这里调用上面的init方法.
如何使用Swift检测锁定/解锁的iOS设备(如Android中的SCRENON/SCREENOFF)
我从PayUMoney网站上下载了PayUMoney iOS SDK.我现在无法将SDK与我的swift项目集成.
swift ×10
ios ×9
objective-c ×5
iphone ×1
mmwormhole ×1
payumoney ×1
pfquery ×1
swift2 ×1
watchkit ×1
xcode ×1