简体   繁体   English

快速声明PHImageRequestOption变量会导致编译器错误

[英]declaring PHImageRequestOption variable in swift gives compiler error

在此处输入图片说明 I am using the following code: 我正在使用以下代码:

PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init]

and it gives me following errors 它给了我以下错误

Consecutive statements on a line must be separated by ';' 行上的连续语句必须用';'分隔

Make sure it's only in one line with trailing semicolon 确保仅在一行中加上尾部分号

NSInteger x = 0 ;
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init] ;
NSInteger y = 0 ;

// //

in swift make it like this 迅速使它像这样

let options = PHImageRequestOptions()

使用swift时,请尝试以下代码:

let options = PHImageRequestOptions()

I usually do not answer to convert my code to Swift for me questions... 对于我的问题,我通常不回答将代码转换为Swift

func exportGifAsset(_ asset: PHAsset) {
    let options = PHImageRequestOptions()
    options.isSynchronous = true
    options.isNetworkAccessAllowed = false
    options.deliveryMode = .highQualityFormat
    //...
}

You should better find a Swift code for your purpose. 您最好为自己的目的找到一个Swift代码。 Nowadays you can find good Swift examples every here and there. 如今,您到处都可以找到良好的Swift示例。

THis code is for oBjective-c 该代码适用于oBjective-c

First add property to .h class 首先将属性添加到.h类

@property (nonatomic, strong) PHImageRequestOptions *requestOptions;

then add below line to your ViewController . 然后ViewController下行添加到您的ViewController

self.requestOptions = [[PHImageRequestOptions alloc] init];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM