小编ris*_*992的帖子

检查给定的PHAsset是iCloud资产吗?

我正在尝试获取PhAsset对象.我想隔离iCloud资产.这是我的代码,

PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:nil];

[cloudAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop){
    if(collection != nil){

        PHFetchResult *result = [PHAsset fetchAssetsInAssetCollection:collection options:fetchOptions];
        [result enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop)
         {
            // check asset is iCloud asset 

         }];
    }

}];
Run Code Online (Sandbox Code Playgroud)

请告诉我如何找到PHAsset是iCloud资产?

ios icloud photosframework phasset

13
推荐指数
3
解决办法
1万
查看次数

swift:声明公共变量

class XYActivity: UIActivity,YouTubeHelperDelegate
{
    var youTubeHelper:YouTubeHelper
    var uploadURL: String!
    override init() {
        self.youTubeHelper = YouTubeHelper()
    }
    override  func activityType() -> String? {
        return nil
    }
//
}
Run Code Online (Sandbox Code Playgroud)

我想将uploadURL公开,即在其他类中分配.当我添加公共领域时,var uploadURL:String!它建议我将其作为内部.我想把它公之于众.请帮忙

variables xcode public ios swift

12
推荐指数
1
解决办法
2万
查看次数

为什么NSIndexPath长度总是显示2?

我创建了一个NSIndexPath对象但是当我打印其length属性的值时,它总是将值显示为2.

 NSIndexPath *index = [NSIndexPath indexPathForItem:0 inSection:4];
Run Code Online (Sandbox Code Playgroud)

{length = 2,path = 4 - 0}

为什么长度总是2?

nsindexpath ios

10
推荐指数
1
解决办法
2439
查看次数

5
推荐指数
1
解决办法
2885
查看次数

APNS:错误域= NSCocoaErrorDomain代码= 3840

我在服务器上注册设备数据,以获得推送通知.这是代码,

[NSURLConnection sendAsynchronousRequest: request
                                           queue: _postQueue
                               completionHandler: ^(NSURLResponse *response, NSData *responseData, NSError *connectionError) {
                                   if (connectionError) {
                                       //
                                   } else {
                                      NSError *error = nil;
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData: responseData options: NSJSONReadingMutableContainers error: &error];
                                   }
                               }];
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x17057f60 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments …
Run Code Online (Sandbox Code Playgroud)

json apple-push-notifications ios sendasynchronousrequest

2
推荐指数
1
解决办法
2万
查看次数