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 · Dec 30, 2016 · 3558 views
    This topic created in 3423 days ago, the information mentioned may be changed or developed.

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

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

    有具体问题欢迎交流.
    luocic
        4
    luocic  
       Feb 3, 2017
    @banxi1988 官方指南是不是 api 里面的全要过一遍,很多类的功能都要先搞清楚吗?
    GitHub 那个库看了,好多东西,一下不知道从哪下手了,我还是先看看官方指南吧,有问题我再回来问你,谢谢您的回复。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2831 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:04 · PVG 20:04 · LAX 05:04 · JFK 08:04
    ♥ Do have faith in what you're doing.