• Stars
    star
    913
  • Rank 50,033 (Top 1.0 %)
  • Language
    Objective-C
  • License
    BSD 2-Clause "Sim...
  • Created almost 12 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Manages blocks of code that only need to run once on version updates in iOS apps.

MTMigration

Build Status Carthage compatible

Manages blocks of code that need to run once on version updates in iOS apps. This could be anything from data normalization routines, "What's New In This Version" screens, or bug fixes.

Installation

MTMigration can be installed one of two ways:

  • Add pod "MTMigration" to your Podfile, import as necessary with: #import <MTMigration/MTMigration.h>.
  • Add MTMigration.{h,m} to your project, import as necessary with: #import "MTMigration.h".

Usage

If you need a block that runs every time your application version changes, pass that block to the applicationUpdateBlock: method.

[MTMigration applicationUpdateBlock:^{
    [metrics resetStats];
}];

If a block is specific to a version, use migrateToVersion:block: and MTMigration will ensure that the block of code is only ever run once for that version.

[MTMigration migrateToVersion:@"1.1" block:^{
    [newness presentNewness];
}];

You would want to run this code in your app delegate or similar.

Parallel methods for migrateToBuild:block: are also available.

Because MTMigration inspects your *-info.plist file for your actual version number and keeps track of the last migration, it will migrate all un-migrated blocks inbetween. For example, let's say you had the following migrations:

[MTMigration migrateToVersion:@"0.9" block:^{
    // Some 0.9 stuff
}];

[MTMigration migrateToVersion:@"1.0" block:^{
    // Some 1.0 stuff
}];

If a user was at version 0.8, skipped 0.9, and upgraded to 1.0, then both the 0.9 and 1.0 blocks would run.

For debugging/testing purposes, you can call reset to clear out the last migration MTMigration remembered, causing all migrations to run from the beginning:

[MTMigration reset];

Notes

MTMigration assumes version numbers are incremented in a logical way, i.e. 1.0.1 -> 1.0.2, 1.1 -> 1.2, etc.

Version numbers that are past the version specified in your app will not be run. For example, if your *-info.plist file specifies 1.2 as the app's version number, and you attempt to migrate to 1.3, the migration will not run.

Blocks are executed on the thread the migration is run on. Background/foreground situations should be considered accordingly.

Contributing

This library does not handle some more intricate migration situations, if you come across intricate use cases from your own app, please add it and submit a pull request. Be sure to add test cases.

Contributors

More Repositories

1

MTAnimation

Animate UIView with 25+ timing functions. (Bounce, elastic, exponential, etc.)
Objective-C
505
star
2

MTDates

A thread safe date calculation library with all the date functions you'll ever need.
Objective-C
343
star
3

MTGeometry

An extension to Core Graphics Geometry. Intersections, scaling, etc.
Objective-C
212
star
4

MTPDF

Objective-C PDF objects. Doing my part to help us stay out of the headache that is Core Foundation.
Objective-C
205
star
5

MTStringAttributes

Easier way to create an attributes dictionary for NSAttributedString
Objective-C
154
star
6

MTControl

Attach block handlers to UIControl objects jQuery style
Objective-C
114
star
7

MTQueue

Add blocks to queues in a super terse and readable way!
Objective-C
61
star
8

MYSCategoryProperties

Quickly add properties to categories using runtime associations.
Objective-C
60
star
9

MTPencil

Draw animated lines (like an invisible pencil) with Core Graphics. (Prototype, will get much better).
Objective-C
47
star
10

MTFittedScrollView

A UIScrollView subclass that resizes itself to fit around its content.
Objective-C
39
star
11

MYSForms

Easy forms for iOS
Objective-C
33
star
12

MYSRuntime

Obj-C Library that makes runtime self-inspection and class modification dead easy.
Objective-C
33
star
13

MTColorDistance

A category on UIColor. Pass in an array of colors and it will return the closest color to the receiver.
Objective-C
24
star
14

MTPocket

Cocoa Web Requests
Objective-C
23
star
15

EKEventToiCal

Returns a string in iCal format for an EKEvent object
Objective-C
22
star
16

MTBlockAlertView

An iOS Alert View that uses block-based delegation instead of protocols.
Objective-C
22
star
17

FatSecretKit

iOS client library for the FatSecret API
Objective-C
21
star
18

MYSSharedSettings

Access local settings and settings shared via iCloud with properties.
Objective-C
20
star
19

MTDateComponentsPicker

A picker for choosing date components. Allows some components to be undefined.
Objective-C
15
star
20

FakeContacts

An XCode project you can build onto the simulator or device to generate any number or random contacts for app testing
Objective-C
13
star
21

MYSCoreText

An Objective-C wrapper around Apple's Core Text framework.
Objective-C
11
star
22

MYSDynamicAlertView

An alert view that uses UIKit Dynamics to present a fun/interactive way to respond to alerts.
Objective-C
9
star
23

flunk

A gem for testing Ruby on Rails web APIs by simulating a client.
Ruby
6
star
24

MYSShared

A submodule that includes objc code that will more than likely be used in any objc project we do.
Objective-C
3
star
25

MTTimer

An Objective-C timer that restricts firing to a time range. If it's called BEFORE min, it waits for min. If it's called AFTER max, it's called at max.
Objective-C
3
star
26

MYSGravityActionSheet

An action sheet that uses UIKit Dynamics to present buttons in a playful, interesting way.
Objective-C
2
star
27

MYSTableView

Objective-C
1
star
28

Pocket

A curl gem that doesn't suck
Ruby
1
star