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
banxi1988
V2EX  ›  iDev

[Swift][Code Generator] 快速生成偏好设置存取代码

  •  
  •   banxi1988 ·
    banxi1988 · 2016-12-30 21:18:53 +08:00 · 3027 次点击
    这是一个创建于 2645 天前的主题,其中的信息可能已经有所发展或是发生改变。

    不少应用都有用到 NSUserDefaults 来存取一些数据. 在没有 元编程的支持下, 读取写入还是有点繁琐. 今天我们介绍的代码生成脚本, 正好可以帮助解决这些问题. 好了, 闲话少说. 直接上动图看看效果.

    Generate Settings

    如下手写几行简单的配置.

    -AppSettings(prefix=app)
    allowMsgNotification:b
    isSoundEnabled:b
    isVirancyEnabled:b
    lastUpdateTime:d
    localNickname:s
    

    选中 -> 右键 -> Services -> generate_settings

    最后是格式化过后的代码图: Generated Code

    最后的最后, 代码生成器项目在:

    https://github.com/banxi1988/iOSCodeGenerator

    4 条回复    2017-02-03 23:04:00 +08:00
    FreshOldMan
        1
    FreshOldMan  
       2016-12-31 23:07:39 +08:00
    老哥,赞一个,天天更新
    luocic
        2
    luocic  
       2017-02-03 15:59:26 +08:00 via iPad
    大神,请教一个问题,最近刚开始学 swift ,看视频练习,进展很慢,然后到现在任然有很多不懂,今天看这个论坛发现了大神,注册只为回复你,请大神赐教,该如何学习?纯新手,还望解答!
    banxi1988
        3
    banxi1988  
    OP
       2017-02-03 22:15:03 +08:00
    @luocic 这是一个比较宽泛的问题. 如果单单以 Swift 来说的话, 我是直接看官方的指南的.
    GitHub 有一个库, 里面整理了不少资料. 看起来挺全的.
    https://github.com/ipader/SwiftGuide

    虽然我不是按这个来学习的. 因为我学习 Swift 时还没有这个仓库.

    有具体问题欢迎交流.
    luocic
        4
    luocic  
       2017-02-03 23:04:00 +08:00
    @banxi1988 官方指南是不是 api 里面的全要过一遍,很多类的功能都要先搞清楚吗?
    GitHub 那个库看了,好多东西,一下不知道从哪下手了,我还是先看看官方指南吧,有问题我再回来问你,谢谢您的回复。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1710 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:43 · PVG 00:43 · LAX 09:43 · JFK 12:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.