This iOS library contains many small bits of code that simplify common iOS tasks.
For example, the iOS SDK has no simple method of showing an alert with a text input (like a JavaScript prompt). So I have a very simple Prompt
class that works like this:
[Prompt title:@"Enter your name" delegate:self selector:@selector(promptComplete:)];
- (void) promptComplete:(NSString*)val
{
NSLog(@"The user entered: %@", val);
}
Right now the code documents itself. Here are a few key features so you'll have an idea of what's inside:
-
Categories on common types like NSString, UIView, NSMutableArray, etc. For example:
NSString* msg = [@"Hello %@" format:@"Josh"];
BOOL contains = [@"OU, TU, OSU, MZU" contains:@"OU"];
[users moveObjectFromIndex:5 toIndex:3];
UIColor* color = [@"990011" hexStringToColor];
-
Core data wrapper for creating, updating, finding, counting, deleting, etc. This is my favorite module of the whole library:
NSArray* products = [CD find:[Product class]];
for(Product* product in products)
product.Description = @"";
[CD save];
-
Easy alerts, prompts, and loading screens:
[Alert show:@"Hello World"];
[Prompt title:@"Enter your name" delegate:self selector:@selector(promptComplete:)];
[Loading show];
[Loading hide];
-
Easily manage app settings
NSString* username = [[SettingsRepository current] getString:@"username" orDefault:@"Unknown"];
[[SettingsRepository current] setString:@"BendyTree" forKey:@"username"];
Some parts of this library have outside dependencies. For example, the string formatting requires a 3rd party Regular Expression library. If you're not using string formatting, then it would be annoying to satisfy that dependency. But no worries - you don't have to.
The BT.h
file controls what pieces of this library compiled. So if you wanted to use string formatting, then you'd set BT_STRING_FORMATTING to 1. See the comments at the top of BT.h
for details.
- Clone this repo into a subfolder of your project
cd my_xcode_project/libs
git clone [email protected]:bendytree/iOS.git bendytree
-
In Xcode, choose "Add Existing Files..." to add these new files
-
Copy
BT-DEMO.h
asBT.h
-
Remove both lines in
BT.h
that say "REMOVE THIS LINE" (this activates the page) -
Add
#import "BT.h"
to your ProjectName-Prefix.pch -
Choose which modules to include (follow directions in
BT.h
)