草庐IT

Swift-Mailer

全部标签

ios - 使用 Swift 3.0 调用 Google Cloud Natural Language API

我正在尝试根据此代码https://cloud.google.com/natural-language/reference/rest/v1/documents向Google的CloudNaturalLanguageAPI提出请求在Swift中,但我不能完全正确地理解语法?importFoundationimportSwiftyJSONclassGoogleNaturalLanguageParser{letsession=URLSession.sharedvargoogleAPIKey="XXX"vargoogleURL:URL{returnURL(string:"https://lan

ios - Swift 协议(protocol)关联类型和继承约束

我想用UICollectionViewController构建一个iOS应用程序每行始终具有相同数量的单元格。因为我不想要我的UICollectionViewController为了处理太多事情,我重构了我的代码并实现了一些有趣的事情,比如protocolassociatedtype和通用类型。现在,我的应用程序由4个不同的.swift组成文件。1。CustomFlowLayout.swiftCustomFlowLayout是UICollectionViewFlowLayout的简单子(monad)类这允许我们设置它的minimumInteritemSpacing,minimumLin

arrays - Swift:addingObjects 方法与 append 方法之间的区别

我目前正在学习用于iOS开发的Swift3,我想知道以下方法之间的区别:ifletmyItemArray=itemObjectas?NSArray{myItemArray.addingObjects(from:[itemTextField.text!])}和以下方法:ifletmyItemArray=itemObjectas?NSArray{myItemArray.append(itemTextField.text!)} 最佳答案 这里有两点需要理解。首先,SwiftArray桥接到Objective-CNSArray。因此,许多C

ios - 获取注释图钉点击事件 MapKit Swift

我有一个类数组。在mkmapview中,我附加了一些注释图钉。varevents=[Events]()foreventinevents{leteventpins=MKPointAnnotation()eventpins.title=event.eventNameeventpins.coordinate=CLLocationCoordinate2D(latitude:event.eventLat,longitude:event.eventLon)mapView.addAnnotation(eventpins)}通过map的委托(delegate),我实现了一个函数funcmapView(

swift - 在后台线程上查询 Realm 并在 UI 线程上解析 ThreadSafeReference 有什么意义吗?

似乎最近添加了ThreadSafeReference以帮助跨越线程边界。之前,根据我阅读的资料(可能并不详尽),建议只在您打算使用结果的线程上查询Realm;在UI线程上有效地查询它。在后台线程上查询Realm是否有好处,或者解析ThreadSafeReference是否基本上再次运行查询?这里有一个使用RxSwift的例子:importRxSwiftimportRealmSwiftpublicstaticfuncgetAllMyModels()->Observable>{returnObservable>>.create{observerin//usingthisqueueinthi

ios - 如何从 ios,swift 中的字符串中获取高质量的条形码图像

我正在使用如下所示的字符串生成带有条形码的图像。classBarCode{classfuncfromString(string:String)->UIImage?{letdata=string.dataUsingEncoding(NSASCIIStringEncoding)letfilter=CIFilter(name:"CICode128BarcodeGenerator")filter!.setValue(data,forKey:"inputMessage")returnUIImage(CIImage:filter!.outputImage!)}}所以这会生成一个准确的图像。但质量很

ios - Swift 中使用 Apollo 的自动 UI 更新不起作用

我有一个小型ApolloiOS应用程序的以下设置,我在TableView中显示了一个session列表,并希望能够将一个session添加到列表:GraphQL:queryAllConferences{allConferences{...ConferenceDetails}}mutationCreateConference($name:String!,$city:String!,$year:String!){createConference(name:$name,city:$city,year:$year){...ConferenceDetails}}fragmentConferenc

ios - Swift - 时区关闭一小时/秒 FromGMT 不正确

这应该是一个非常简单的问题,但我似乎无法理解它。鉴于我的时区是美国东部时间(GMT-4),为什么GMT的04:00变成23:00而不是00:00?//Theoffsetis-4hoursletoffsetFromGMT=Calendar.current.timeZone.secondsFromGMT()/60/60//2017-03-1204:00vardestinationComponents=DateComponents()destinationComponents.timeZone=TimeZone(secondsFromGMT:0)destinationComponents.y

ios - Swift 获取 Facebook AccessToken

我正在尝试获取Facebook访问token。当我打印accessToken时,它返回一个带有appId和authenticationToken的对象,我如何解析出token?我正在使用以下代码:letloginManager=LoginManager()loginManager.logIn([.publicProfile,.userFriends,.email],viewController:self){loginResultinswitchloginResult{case.failed(leterror):print(error)case.cancelled:print("User

ios - 使用 swift 3 解码字符串

我在网络服务响应中得到以下编码字符串\U00e0\U00aa\U0095\U00e0\U00ab\U0083\U00e0\U00aa\U00aa\U00e0\U00aa\U00be\U00e0\U00aa\U0095\U00e0\U00aa\U00b0\U00e0\U00ab\U0080\U00e0\U00aa\U00a8\U00e0\U00ab\U0087\U00e0\U00aa\U009f\U00e0\U00ab\U008b\U00e0\U00aa\U00a1\U00e0\U00aa\U008f\U00e0\U00aa\U00aa\U00e0\U00ab\U008d\U00e0\U