V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
belanote
V2EX  ›  iDev

关于 ALAsset 如何保存

  •  
  •   belanote · 2015-03-20 19:23:08 +08:00 · 2702 次点击
    这是一个创建于 3326 天前的主题,其中的信息可能已经有所发展或是发生改变。
    ALAsset 对象怎样才能持久化保存下来。。。我在多选完照片之后获取到每个照片的 ALAsset 对象保存在数组中,希望能把这个数组保存下来,在我退出程序后再打开 进入选择照片的页面 能够标记出我上次选中的照片
    6 条回复    2015-03-24 10:20:39 +08:00
    enjoeq
        1
    enjoeq  
       2015-03-20 20:23:30 +08:00
    可以持久化这个 ALAset 数组的 representation 的 url,然后在下次打开时遍历照片的 ALAsset,对比你记录的 url 是否和照片的 url 相等,如果相等可以标记这个照片。
    代码大概类似于这样吧:
    if([asset.defaultRepresentation.url isEqual:url]) {

    }
    belanote
        2
    belanote  
    OP
       2015-03-21 10:11:20 +08:00
    哦? 我试试
    belanote
        3
    belanote  
    OP
       2015-03-21 10:11:44 +08:00
    @enjoeq 我试试
    belanote
        4
    belanote  
    OP
       2015-03-23 17:20:25 +08:00
    @enjoeq 亲 貌似还是不行啊 我把 url 取出来 存在数组里,写入文件就失败
    enjoeq
        5
    enjoeq  
       2015-03-24 09:11:23 +08:00
    @belanote 你是直接保存 url 的?转成 NSString 后再保存应该是可以的吧.
    belanote
        6
    belanote  
    OP
       2015-03-24 10:20:39 +08:00
    @enjoeq valueForProperty:ALAssetPropertyAssetURL 这样返回的就是 NSString 啊 这样也是失败的。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   883 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:02 · PVG 05:02 · LAX 14:02 · JFK 17:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.