This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String REGEX_TIMERANGE = "(?:AM|PM)?([0-90-9]{1,2})[::\\.]([0-90-9]{1,2})[\uff5e\u301c-―-](?:AM|PM)?([0-90-9]{1,2})[::\\.]([0-90-9]{1,2})"; | |
public static final Pattern PATTERN_TIMERANGE = Pattern.compile(REGEX_TIMERANGE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "MMGClient.h" | |
// アプリケーションのデリゲート。Geomonにログインするため、MMGRequestDelegateのプロトコルが実装される。 | |
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate, MMGRequestDelegate> | |
// 他のプロパティの定義... | |
// Geomonのクライアントオブジェクト | |
@property (strong, nonatomic) MMGClient *client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MMGClient *client = ... | |
// ユーザーIDはサーバーで既に登録されるか確認する。 | |
// デリゲートがnilすると、同期してリクエストをする。 | |
MMGObject *checkUserObj = [client checkAvailabilityOfUserId:@"baabaablacksheep" withDelegate:nil]; | |
if (checkUserObj.error != nil || checkUserObj.type != kMMGUser) { | |
NSLog(@"ユーザー確認のエラーが発生しました: %@", [checkUserObj.error localizedDescription]); | |
} else { | |
// タイプはkMMGUserの場合は、安全にMMGUserにキャストできる。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MMGClient *client = ... | |
MMGObject *registerUserObj = [client registerUserWithId:@"baabaa" | |
name:@"Baa Baa Black Sheep" | |
email:@"[email protected]" | |
password:@"moomoo" | |
delegate:nil]; | |
if (registerUserObj.error != nil || registerUserObj.type != kMMGUser) { | |
NSLog(@"ユーザー登録のエラーが発生しました: %@", [registerUserObj.error localizedDescription]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 非同期的にユーザーを登録する。 | |
*/ | |
- (void)registerUserUsingClient:(MMGClient *)client | |
{ | |
[client registerUserWithId:@"baabaa" | |
name:@"Baa Baa Black Sheep" | |
email:@"[email protected]" | |
password:@"moomoo" | |
delegate:self]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray *)fetchRecordsForEntity:(NSString *)entityName | |
{ | |
return [self fetchRecordsForEntity:entityName orderBy:nil]; | |
} | |
- (NSArray *)fetchRecordsForEntity:(NSString *)entityName orderBy:(NSString *)column | |
{ | |
NSError *error = nil; | |
NSManagedObjectContext *managedObjectContext = [self managedObjectContext]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | |
{ | |
return (interfaceOrientation == UIInterfaceOrientationPortrait); | |
} | |
- (NSUInteger)supportedInterfaceOrientations { | |
return UIInterfaceOrientationMaskPortrait; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSArray *objectRegistry; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
objectRegistry = [[NSArray alloc] initWithObjects:obj1, obj2, nil]; | |
}); | |
return objectRegistry[index]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
uint64_t doubleToBits(double x) { | |
const union { double f; uint64_t i; } xUnion = { .f = x }; | |
return xUnion.i; | |
} | |
uint32_t floatToBits(float x) { | |
const union { float f; uint32_t i; } xUnion = { .f = x }; | |
return xUnion.i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted from following sources: | |
# https://github.com/jverkoey/iOS-Framework | |
# http://codefriend.blogspot.jp/2011/09/creating-ios-framework-with-xcode4.html | |
# http://www.cocoanetics.com/2010/04/making-your-own-iphone-frameworks/ | |
# "No architecture.." error resolved by trying some of these: | |
# http://stackoverflow.com/questions/6151549/how-can-i-build-a-specific-architecture-using-xcodebuild | |
set -e | |
set +u |