我对AREL很新,并且在查找使用Postgres JSONB和AREL的参考时遇到了麻烦。
我如何将此SQL转换为AREL语句?
//获取自定义相册
- (PHAssetCollection *)getAPPCollection {
// Getting the app album if any: 找是否已经创建自定义相册
PHFetchResult<PHAssetCollection *> *collectionResult = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
for (PHAssetCollection *collection in collectionResult) {
if ([collection.localizedTitle isEqualToString:appName]) {
return collection;
}
}
// Creating the album: 新建自定义相册
__block NSString *collectionId = nil;
NSError *error = nil;
[[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:^{
collectionId = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:appName].placeholderForCreatedAssetCollection.localIdentifier;
} error:&error];
if (error) {
NSLog(@"创建相册:%@失败", appName);
return nil;
}
return [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[collectionId] options:nil].lastObject;
}