草庐IT

Swift-Mailer

全部标签

ios - 如何在 Swift 中创建和访问 NSDictionary

我正忙于转换为Swift并试图弄清楚如何在Swift中执行以下操作NSArrayarrayOfStrings1={@"Substring1",@"Substring2",nil};Dictionarydict={@"MainString1",arrayOfStrings1};所以在Swift中我有以下内容:vardictionary=[String:Array]()//isthiscorrect??vararray:[String]=["Substring1","Substring2"]dictionary["MainString1"]=["Substring1.1","Substri

swift - 如何将字节转换为字符串?

我需要将我的Byte转换为String因为-(NSInteger)write:(constuint8_t*)buffermaxLength:(NSUInteger)将String作为其第一个参数。我想要的:funcsendMessage(message:Byte)->Int{returnoutputStream!.write(message,maxLength:1)} 最佳答案 您不必提供字符串,但是UnsafePointer.只需添加message与&:returnoutputStream!.write(&message,maxL

swift - 如何比较 NSPersistentStoreUbiquitousTransitionType 枚举值

尝试使用此方法比较从NSPersistentStoreCoordinatorStoresDidChangeNotification接收到的值时出现以下错误//Checktypeoftransitioniflettype=n.userInfo?[NSPersistentStoreUbiquitousTransitionTypeKey]as?UInt{FLOG("transitiontypeis\(type)")if(type==NSPersistentStoreUbiquitousTransitionType.InitialImportCompleted){FLOG("transitio

swift - 如何快速将 didSelectRowAtIndexPath 发送回 View Controller

我在swift中有1个viewController和1个tableViewController。我可以从viewController发送一个NSMutableArray来使用segue填充tableViewController。我不知道如何将选定的行发送回ViewController。到目前为止的代码:overridefunctableView(tableView:UITableView,didSelectRowAtIndexPathindexPath:NSIndexPath){println("Youselectedcell#\(indexPath.row)!")//Missingc

pointers - Swift:不能在数组中存储不安全的指针

我创建了一个小的结构来保存版本号。现在我搜索了一种紧凑的方法来将数字直接解析为结构的变量。我试图以这种方式实现它:structVersion{varmajor:Int=0varminor:Int=0varrevision:Int=0init(string:String){letcomponents=string.componentsSeparatedByString(".")if1...3~=components.count{vartargets=[&major,&minor,&revision]forindexin0...2{varscanner=NSScanner(string:c

ios - "' CGFloat ' is not convertible to ' Swift 中的双 '"错误 (iOS)

我正在尝试在Swift中将一张图片切割成9block。我收到此错误:'CGFloat'isnotconvertibleto'Double'当我将i或j放入两个变量时出现此错误。下面是用于裁剪图片的部分代码。foriin1...3{forjin1...3{varintWidth=(i*(sizeOfImage.width/3.0))varfltHeight=(j*(sizeOfImage.height/3.0))varportion=CGRectMake(intWidth,fltHeight,sizeOfImage.width/3.0,sizeOfImage.height/3.0);..

swift - 如何在 swift 中定义显式转换运算符?

背景我有一个想要隐藏实现细节的类。classFoo{vari:Int}letf=Foo()有没有一种方法可以定义显式转换运算符,以便在fasInt上调用它?如果没有,是否有我应该使用的规范方法名称,如asInt()->Int? 最佳答案 我不知道这是你想要的,但你可以像Int初始化器一样实现强制转换:extensionInt{init(_foo:Foo){self=foo.i}}letf=Foo()f.i=12letintVal=Int(f)//->12 关于swift-如何在swift

ios - 如何在 Swift 中适配 Mashape 应用程序 key ?

我尝试使用Mashape的“YodaSpeak”API。我得到了二进制数据,但我不知道如何解析数据。当我尝试打印数据时,收到此消息。“(消息,缺少Mashape应用程序key。转到https://www.mashape.com获取您的key。)”我认为Mashape应用程序key是“jY0bEhHCBpmsh8j1mpA5p11tCJGyp1tok3Zjsn4ubbvNNp5Jt3”。如何在Swift中适配这个键?funcresponse(res:NSURLResponse!,data:NSData!,error:NSError!){letjson:NSDictionary=NSJSO

objective-c - 在初始化它的方法的完成 block 中检查 Swift 变量的值

以在Objective-C中创建NSURLSessionDownloadTask为例:NSURLSessionDownloadTask*task=[[NSURLSessionsharedSession]downloadTaskWithURL:[NSURLURLWithString:@"google.com"]completionHandler:^(NSURL*location,NSURLResponse*response,NSError*error){if(task.state==NSURLSessionTaskStateCompleted){//Dothings}}];[taskre

objective-c - Swift/Objective S3 文件上传

我正在尝试使用最近发布的新版本的AWS,我的旧版本在android上运行,但我是swift的新手,而我是AWSS3的新版本,最近几天被阻止了这个问题。我不断收到操作无法完成的错误消息。(cocoa错误260。)这是我的应用委托(delegate)funcapplication(application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[NSObject:AnyObject]?)->Bool{letcredentialsProvider=AWSCognitoCredentialsProvider.creden