Latest 0.2.0
Homepage https://github.com/Mindera/MDResourceManager
License MIT
Platforms ios 7.0, requires ARC
Authors

Build Status
Version
License
Platform

iOS Resource Management, the Android way.

Provide resources independently of your code. Manage different sizes, strings depending on the device type or orientation.
Inspired in the Resource management of Android.

Easily extended, you can provide your own criterias. e.g. handle different values depending on your product jurisdictions.

How it works

It is inspired by the resource management in Android . It is a simpler version, with less rules, and adapted to the iOS ecosystem.

You can create resource files that apply only when some criterias are meet.
You can create a resource file name "resources-ipad-land.plist". and another "resources-ipad-port.plist".
If you are using an ipad in landscape the values returned will be from the first file.

The rules are defined in the following table, each configuration has its own qualifier values that you can use in your resource filename.

Configuration Qualifier values Description
Device model e.g. ipad iphone iphone6 iphon6plus Specify the device model. You can be specific to apply the rule to more cases, or have a criteria more generic
Orientation e.g. port land Device orientation

Usage

Create resource files

The first step is to create your resource files with .plist extension, with your criterias.

Resource files

Create the MDResourceManager

Create a MDResourceManager and give it your criterias. Bear in mind that the order is important, the best match algoritm considers the order you give your criterias.

You can also create your own criterias.


NSArray *criterias = @[[[MDDeviceResourceCriteria alloc] init],
                       [[MDOrientationResourceCriteria alloc] init]];

MDResourceManager *resourceManager = [[MDResourceManager alloc] initWithPrefixFileName:@"dimensions"
                                                                             criterias:criterias];

[resourceManager loadResources];

Ask the manager for values


CGFloat labelFontSize1 = [resourceManager floatForKey:@"labelFontSize1"];
CGFloat labelFontSize2 = [resourceManager floatForKey:@"labelFontSize2"];

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

MDResourceManager is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "MDResourceManager"

Author

Joao Prudencio, [email protected]

License

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

Latest podspec

{
    "name": "MDResourceManager",
    "version": "0.2.0",
    "summary": "iOS Resource Management, the Android way",
    "description": "Provide resources independently of your code. Manage different sizes, strings depending on the device type or orientation.n* Inspired in the Resource management of Android.n* Easily extended, you can provide your own criterias. e.g. handle different values depending on your product jurisdictions.",
    "homepage": "https://github.com/Mindera/MDResourceManager",
    "license": "MIT",
    "authors": {
        "Joao Prudencio": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Mindera/MDResourceManager.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "subspecs": [
        {
            "name": "Manager",
            "source_files": "Pod/Classes/Manager",
            "dependencies": {
                "MDResourceManager/Filter": [],
                "MDResourceManager/Parser": [],
                "MDResourceManager/Criteria": []
            }
        },
        {
            "name": "Filter",
            "source_files": "Pod/Classes/Filter",
            "dependencies": {
                "MDResourceManager/Criteria": [],
                "MDResourceManager/Resource": []
            }
        },
        {
            "name": "Criteria",
            "source_files": "Pod/Classes/Criteria",
            "dependencies": {
                "MDResourceManager/Util": []
            }
        },
        {
            "name": "Resource",
            "source_files": "Pod/Classes/Resource",
            "dependencies": {
                "MDResourceManager/Criteria": []
            }
        },
        {
            "name": "Parser",
            "source_files": "Pod/Classes/Parser",
            "dependencies": {
                "MDResourceManager/Criteria": [],
                "MDResourceManager/Resource": []
            }
        },
        {
            "name": "Util",
            "source_files": "Pod/Classes/Util"
        }
    ]
}

Pin It on Pinterest

Share This