diff --git a/Marshmallows.xcodeproj/project.pbxproj b/Marshmallows.xcodeproj/project.pbxproj index 6547281..34057ee 100644 --- a/Marshmallows.xcodeproj/project.pbxproj +++ b/Marshmallows.xcodeproj/project.pbxproj @@ -7,24 +7,40 @@ objects = { /* Begin PBXBuildFile section */ - 7BD100A2141341EB00A9921B /* MMHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BD100A0141341EB00A9921B /* MMHTTPClient.h */; }; + 7B13A56E1415CE360033DCC2 /* libMarshmallows.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BE32D0614132EE4008F2DEA /* libMarshmallows.a */; }; + 7B2C8D7614159642004E1123 /* UIAlertView+simple.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B2C8D7414159642004E1123 /* UIAlertView+simple.h */; }; + 7B2C8D7714159642004E1123 /* UIAlertView+simple.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B2C8D7514159642004E1123 /* UIAlertView+simple.m */; }; + 7B2C8D811415C450004E1123 /* UIAlertViewDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B2C8D7F1415C450004E1123 /* UIAlertViewDelegate.h */; }; + 7B2C8D821415C450004E1123 /* UIAlertViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B2C8D801415C450004E1123 /* UIAlertViewDelegate.m */; }; + 7BD100A2141341EB00A9921B /* MMHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BD100A0141341EB00A9921B /* MMHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7BD100A3141341EB00A9921B /* MMHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BD100A1141341EB00A9921B /* MMHTTPClient.m */; }; - 7BD100A614134FBE00A9921B /* MMHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BD100A414134FBE00A9921B /* MMHTTPRequest.h */; }; + 7BD100A614134FBE00A9921B /* MMHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BD100A414134FBE00A9921B /* MMHTTPRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7BD100A714134FBE00A9921B /* MMHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BD100A514134FBE00A9921B /* MMHTTPRequest.m */; }; 7BD100AA141353B700A9921B /* NSDate+relative.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BD100A8141353B700A9921B /* NSDate+relative.h */; }; 7BD100AB141353B700A9921B /* NSDate+relative.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BD100A9141353B700A9921B /* NSDate+relative.m */; }; + 7BD100AC141364A900A9921B /* Marshmallows.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE32D0E14132EE4008F2DEA /* Marshmallows.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7BD100D714136F7500A9921B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BD100B61413675100A9921B /* UIKit.framework */; }; + 7BD100D814136F7500A9921B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BE32D0914132EE4008F2DEA /* Foundation.framework */; }; + 7BD100D914136F7500A9921B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BD100B91413675100A9921B /* CoreGraphics.framework */; }; 7BE32D0A14132EE4008F2DEA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BE32D0914132EE4008F2DEA /* Foundation.framework */; }; 7BE32D6A14133618008F2DEA /* NSString+sanity.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE32D6814133618008F2DEA /* NSString+sanity.h */; }; 7BE32D6B14133618008F2DEA /* NSString+sanity.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BE32D6914133618008F2DEA /* NSString+sanity.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 7B2C8D7414159642004E1123 /* UIAlertView+simple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAlertView+simple.h"; sourceTree = ""; }; + 7B2C8D7514159642004E1123 /* UIAlertView+simple.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertView+simple.m"; sourceTree = ""; }; + 7B2C8D7F1415C450004E1123 /* UIAlertViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIAlertViewDelegate.h; sourceTree = ""; }; + 7B2C8D801415C450004E1123 /* UIAlertViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIAlertViewDelegate.m; sourceTree = ""; }; 7BD100A0141341EB00A9921B /* MMHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMHTTPClient.h; sourceTree = ""; }; 7BD100A1141341EB00A9921B /* MMHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMHTTPClient.m; sourceTree = ""; }; 7BD100A414134FBE00A9921B /* MMHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMHTTPRequest.h; sourceTree = ""; }; 7BD100A514134FBE00A9921B /* MMHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMHTTPRequest.m; sourceTree = ""; }; 7BD100A8141353B700A9921B /* NSDate+relative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+relative.h"; sourceTree = ""; }; 7BD100A9141353B700A9921B /* NSDate+relative.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+relative.m"; sourceTree = ""; }; + 7BD100B41413675100A9921B /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + 7BD100B61413675100A9921B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 7BD100B91413675100A9921B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; 7BE32D0614132EE4008F2DEA /* libMarshmallows.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMarshmallows.a; sourceTree = BUILT_PRODUCTS_DIR; }; 7BE32D0914132EE4008F2DEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 7BE32D0D14132EE4008F2DEA /* Marshmallows-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Marshmallows-Prefix.pch"; sourceTree = ""; }; @@ -82,6 +98,10 @@ 7BD100A9141353B700A9921B /* NSDate+relative.m */, 7BE32D6814133618008F2DEA /* NSString+sanity.h */, 7BE32D6914133618008F2DEA /* NSString+sanity.m */, + 7B2C8D7414159642004E1123 /* UIAlertView+simple.h */, + 7B2C8D7514159642004E1123 /* UIAlertView+simple.m */, + 7B2C8D7F1415C450004E1123 /* UIAlertViewDelegate.h */, + 7B2C8D801415C450004E1123 /* UIAlertViewDelegate.m */, 7BE32D0C14132EE4008F2DEA /* Supporting Files */, ); path = Marshmallows; @@ -102,10 +122,13 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 7BE32D6A14133618008F2DEA /* NSString+sanity.h in Headers */, + 7BD100AC141364A900A9921B /* Marshmallows.h in Headers */, 7BD100A2141341EB00A9921B /* MMHTTPClient.h in Headers */, 7BD100A614134FBE00A9921B /* MMHTTPRequest.h in Headers */, + 7BE32D6A14133618008F2DEA /* NSString+sanity.h in Headers */, 7BD100AA141353B700A9921B /* NSDate+relative.h in Headers */, + 7B2C8D7614159642004E1123 /* UIAlertView+simple.h in Headers */, + 7B2C8D811415C450004E1123 /* UIAlertViewDelegate.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -163,6 +186,8 @@ 7BD100A3141341EB00A9921B /* MMHTTPClient.m in Sources */, 7BD100A714134FBE00A9921B /* MMHTTPRequest.m in Sources */, 7BD100AB141353B700A9921B /* NSDate+relative.m in Sources */, + 7B2C8D7714159642004E1123 /* UIAlertView+simple.m in Sources */, + 7B2C8D821415C450004E1123 /* UIAlertViewDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -216,7 +241,10 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Marshmallows/Marshmallows-Prefix.pch"; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-all_load", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; @@ -229,7 +257,10 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Marshmallows/Marshmallows-Prefix.pch"; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-all_load", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; diff --git a/Marshmallows/Marshmallows.h b/Marshmallows/Marshmallows.h index d7a75ba..0d703cb 100644 --- a/Marshmallows/Marshmallows.h +++ b/Marshmallows/Marshmallows.h @@ -10,3 +10,4 @@ #import "NSDate+relative.h" #import "NSString+sanity.h" +#import "UIAlertView+simple.h" diff --git a/Marshmallows/UIAlertView+simple.h b/Marshmallows/UIAlertView+simple.h new file mode 100644 index 0000000..b91239e --- /dev/null +++ b/Marshmallows/UIAlertView+simple.h @@ -0,0 +1,17 @@ +// +// UIAlertView+simple.h +// DatingX +// +// Created by Sami Samhuri on 11-08-24. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import + +typedef void (^UIAlertViewCallback)(BOOL ok); + +@interface UIAlertView (UIAlertView_simple) + ++ (void) showAlertWithTitle: (NSString *)title message: (NSString *)message; + +@end diff --git a/Marshmallows/UIAlertView+simple.m b/Marshmallows/UIAlertView+simple.m new file mode 100644 index 0000000..04f106a --- /dev/null +++ b/Marshmallows/UIAlertView+simple.m @@ -0,0 +1,32 @@ +// +// UIAlertView+simple.m +// DatingX +// +// Created by Sami Samhuri on 11-08-24. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import "UIAlertView+simple.h" +#import "UIAlertViewDelegate.h" + +@implementation UIAlertView (UIAlertView_simple) + ++ (void) showAlertWithTitle: (NSString *)title message: (NSString *)message +{ + [[[[self alloc] initWithTitle: title + message: message + delegate: nil + cancelButtonTitle: @"OK" + otherButtonTitles: nil] autorelease] show]; +} + ++ (void) confirmWithTitle: (NSString *)title message: (NSString *)message then: (UIAlertViewCallback)callback +{ + [[[[self alloc] initWithTitle: title + message: message + delegate: [UIAlertViewDelegate alertViewDelegateWithCallback: callback] + cancelButtonTitle: @"Cancel" + otherButtonTitles: @"OK", nil] autorelease] show]; +} + +@end diff --git a/Marshmallows/UIAlertViewDelegate.h b/Marshmallows/UIAlertViewDelegate.h new file mode 100644 index 0000000..5cf5c57 --- /dev/null +++ b/Marshmallows/UIAlertViewDelegate.h @@ -0,0 +1,20 @@ +// +// UIAlertViewDelegate.h +// Marshmallows +// +// Created by Sami Samhuri on 11-09-05. +// Copyright 2011 Guru Logic. All rights reserved. +// + +#import +#import "UIAlertView+simple.h" + +@interface UIAlertViewDelegate : NSObject +{ + UIAlertViewCallback _callback; +} + ++ (id) alertViewDelegateWithCallback: (UIAlertViewCallback)callback; +- (id) initWithCallback: (UIAlertViewCallback)callback; + +@end diff --git a/Marshmallows/UIAlertViewDelegate.m b/Marshmallows/UIAlertViewDelegate.m new file mode 100644 index 0000000..4c9f19d --- /dev/null +++ b/Marshmallows/UIAlertViewDelegate.m @@ -0,0 +1,39 @@ +// +// UIAlertViewDelegate.m +// Marshmallows +// +// Created by Sami Samhuri on 11-09-05. +// Copyright 2011 Guru Logic. All rights reserved. +// + +#import "UIAlertViewDelegate.h" + +@implementation UIAlertViewDelegate + ++ (id) alertViewDelegateWithCallback: (UIAlertViewCallback)callback +{ + return [[[self alloc] initWithCallback: callback] autorelease]; +} + +- (id) initWithCallback: (UIAlertViewCallback)callback +{ + self = [super init]; + if (self) { + _callback = Block_copy(callback); + } + return self; +} + +- (void) alertView: (UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex +{ + BOOL ok = (buttonIndex == 1); + _callback(ok); +} + +- (void) dealloc +{ + [_callback release]; + [super dealloc]; +} + +@end