Coder Social home page Coder Social logo

antiwise / remoteconfig Goto Github PK

View Code? Open in Web Editor NEW

This project forked from getsling/remoteconfig

0.0 0.0 0.0 403 KB

Objective-c library for loading a remote JSON / XML config file with locally defined default values.

License: MIT License

Objective-C 95.85% Ruby 4.15%

remoteconfig's Introduction

RemoteConfig

Badge w/ Version Badge w/ Platform

Objective-c library for loading a remote JSON / XML config file with locally defined default values.

Installation

The best and easiest way is to use CocoaPods.

pod 'RemoteConfig'

How to get started

Create a subclass of GVJSONRemoteConfig or GVXMLRemoteConfig and override the following methods:

  • - (NSURL *)remoteFileLocation; (required)
  • - (void)setupMapping; (required)
  • - (NSTimeInterval)redownloadRate; (optional, by default the remote file is redownloaded every 24 hours)

It's recommended to add synthesized properties for your config values. However, key value coding also works.

Example

See the included example app: Config.m and ViewController.m.

To run the example app, install its dependancies via CocoaPods: pod install.

@interface Config : GVJSONRemoteConfig

@property (strong, nonatomic) NSNumber *exampleIntegerValue;
@property (strong, nonatomic) NSString *exampleStringValue;
@property (strong, nonatomic) NSString *nonExistingStringValue;

+ (Config *)sharedInstance;

@end
@implementation Config

+ (Config *)sharedInstance {
    static dispatch_once_t pred;
    static Config *sharedInstance = nil;
    dispatch_once(&pred, ^{ sharedInstance = [[self alloc] init]; });
    return sharedInstance;
}

- (NSURL *)remoteFileLocation {
    return [NSURL URLWithString:@"https://raw.github.com/gangverk/RemoteConfig/master/Example/example.json"];
}

- (void)setupMapping {
    [self mapRemoteKeyPath:@"remote_integer_value" toLocalAttribute:@"exampleIntegerValue" defaultValue:[NSNumber numberWithInteger:1]];
    [self mapRemoteKeyPath:@"remote_string_value" toLocalAttribute:@"exampleStringValue" defaultValue:@"Default local value"];
    [self mapRemoteKeyPath:@"nonexisting_string_value" toLocalAttribute:@"nonExistingStringValue" defaultValue:@"Default local value for nonexisting value on server"];
}

@end

Requirements

  • iOS 5
  • ARC
  • Xcode 4.4 or higher

Issues and questions

Have a bug? Please create an issue on GitHub!

To do

The following items are on the to do list:

  • Check the last-modified header so we don't parse data if it wasn't changed (using NSURLRequestReloadRevalidatingCacheData already limits downloading, but we're still always parsing the old data)
  • Add tests

Apps using RemoteConfig

  • Last.fm Scrobbler
  • MetroLyrics
  • Radio.com
  • Tailgate Fan

Are you using RemoteConfig in your iOS or Mac OS X app? Send a pull request with an updated README.md file to be included.

License

RemoteConfig is available under the MIT license. See the LICENSE file for more info.

remoteconfig's People

Contributors

atlithorn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.