これだけ。自分のリポジトリに Forkされたリポジトリが作成される。
一旦、Fork したものは自分ですきなようにできる。例では MTStatusBarOverlay というライブラリを Fork してみた。
このライブラリにはサンプルアプリが付いていなかったので自分で作ってみる。Forkした先ほどのリポジトリを Clone して手元の PCへ持ってくる。
(参考)
Xcode でプロジェクトを開き、新しいターゲットを追加する。

iOS/iPhone/iPad/MacOSX プログラミング, Objective-C, Cocoaなど
2011年11月25日金曜日 | Published in github | 0 コメント

2011年11月24日木曜日 | Published in Mac OS X 10.7, XPC | 0 コメント
static void TestService_peer_event_handler(xpc_connection_t peer, xpc_object_t event)
{
xpc_type_t type = xpc_get_type(event);
if (type == XPC_TYPE_ERROR) {
if (event == XPC_ERROR_CONNECTION_INVALID) {
// The client process on the other end of the connection has either
// crashed or cancelled the connection. After receiving this error,
// the connection is in an invalid state, and you do not need to
// call xpc_connection_cancel(). Just tear down any associated state
// here.
} else if (event == XPC_ERROR_TERMINATION_IMMINENT) {
// Handle per-connection termination cleanup.
}
} else {
assert(type == XPC_TYPE_DICTIONARY);
// Handle the message.
}
}
static void TestService_event_handler(xpc_connection_t peer)
{
// By defaults, new connections will target the default dispatch
// concurrent queue.
xpc_connection_set_event_handler(peer, ^(xpc_object_t event) {
TestService_peer_event_handler(peer, event);
});
// This will tell the connection to begin listening for events. If you
// have some other initialization that must be done asynchronously, then
// you can defer this call until after that initialization is done.
xpc_connection_resume(peer);
}
int main(int argc, const char *argv[])
{
xpc_main(TestService_event_handler);
return 0;
一種のサーバとして動作するのでイベントが来たときの処理を書いていく。xpc_connection_cancel xpc_connection_create xpc_connection_get_asid xpc_connection_get_context xpc_connection_get_egid xpc_connection_get_euid xpc_connection_get_name xpc_connection_get_pid xpc_connection_resume xpc_connection_send_message xpc_connection_send_message_with_reply xpc_connection_send_message_with_reply_sync xpc_connection_set_context xpc_connection_set_event_handler xpc_connection_set_finalizer_f xpc_connection_set_target_queue xpc_connection_suspend
2011年11月21日月曜日 | Published in | 2 コメント
2011年11月19日土曜日 | Published in ios 4.3, iOS 5.0 | 0 コメント
// UIWindow.h
UIKIT_EXTERN NSString *const UIKeyboardWillChangeFrameNotification
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
Check the availability of an external (extern) constant or a notification
name by explicitly comparing its address—and not the symbol’s bare name—to NULL or nil.
if (&UIKeyboardWillChangeFrameNotification != NULL) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillChangeFrame:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
2011年11月18日金曜日 | Published in 情報, 情報/2011-11-20, 情報/開発/テクニック | 0 コメント
| Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
AFHTTPClient AFHTTPRequestOperation AFImageCache AFImageRequestOperation AFJSONRequestOperation AFNetworkActivityIndicatorManager AFPropertyListRequestOperation AFURLConnectionOperation AFXMLRequestOperation Protocol References AFMultipartFormData UIImageView(AFNetworking)基本となるHTTPアクセスの他、画像のキャッシュや JSON/XML/PropertyList処理なども用意されている。
// JSON Request
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:@"https://gowalla.com/users/mattt.json"]];
AFJSONRequestOperation *operation =
[AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"],
[JSON valueForKeyPath:@"last_name"]);
} failure:nil];
NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
[queue addOperation:operation];データの種類ごと(上記例は JSON)に用意された AFHTTPRequestOperation を作成し、ここに Blocksで成功時の処理を書いておく。それを最後に NSOperationQueue へ投入するだけ。いくつかステップを踏む必要はあるが元々の NSOperation系APIを素直に活用しているので汎用性がある(あ、 JSONライブラリを別途用意する必要も無いのか)。// Image Request
UIImageView *imageView = [[UIImageView alloc]
initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
[imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];URLから画像を取得して直接 UIImageViewを作成するメソッドもある。これは簡単でいいかも。// File Upload with Progress Callback NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5); NSMutableURLRequest *request = [[AFHTTPClient sharedClient] multipartFormRequestWithMethod:@"POST" path:@"/upload" parameters:nil constructingBodyWithBlock: ^(idPOST/マルチパートによるファイルアップロード処理。簡潔でわかりやすい。setUploadProgressBlock: で進捗状況をハンドリング可能。formData) { [formData appendPartWithFileData:data mimeType:@"image/jpeg" name:@"avatar"]; }]; AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease]; [operation setUploadProgressBlock: ^(NSUInteger totalBytesWritten, NSUInteger totalBytesExpectedToWrite) { NSLog(@"Sent %d of %d bytes", totalBytesWritten, totalBytesExpectedToWrite); }]; NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease]; [queue addOperation:operation];
| Published in 情報, 情報/2011-11-20, 情報/開発/プロモーション | 0 コメント
2011年11月17日木曜日 | Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
typedef void (^ReachabilityHandler)(NPReachability *curReach); - (id)addHandler:(ReachabilityHandler)handler; @property (nonatomic, readonly, getter=isCurrentlyReachable) BOOL currentlyReachable; @property (nonatomic, readonly) SCNetworkReachabilityFlags currentReachabilityFlags;
| Published in 情報, 情報/2011-11-20, 情報/開発/iOS5, 情報/開発/チュートリアル | 0 コメント
| Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
HGPageScrollView *pageScrollView = [[[NSBundle mainBundle] loadNibNamed:@"HGPageScrollView" owner:self options:nil] objectAtIndex:0]; [self.view addSubview:pageScrollView];サンプルではページの定義を XIBファイルで行っていた。XIBで定義すれば容易にカスタマイズできる。
@protocol HGPageScrollViewDataSource@required // Page display. Implementers should *always* try to reuse pageViews by setting each page's reuseIdentifier. // This mechanism works the same as in UITableViewCells. - (HGPageView *)pageScrollView:(HGPageScrollView *)scrollView viewForPageAtIndex:(NSInteger)index; @optional - (NSInteger)numberOfPagesInScrollView:(HGPageScrollView *)scrollView; // Default is 1 if not implemented // you should re-use the UIView that you return here, only initialize it with appropriate values. - (UIView *)pageScrollView:(HGPageScrollView *)scrollView headerViewForPageAtIndex:(NSInteger)index; - (NSString *)pageScrollView:(HGPageScrollView *)scrollView titleForPageAtIndex:(NSInteger)index; - (NSString *)pageScrollView:(HGPageScrollView *)scrollView subtitleForPageAtIndex:(NSInteger)index; @end
@protocol HGPageScrollViewDelegate@optional // Dragging - (void) pageScrollViewWillBeginDragging:(HGPageScrollView *)scrollView; - (void) pageScrollViewDidEndDragging:(HGPageScrollView *)scrollView willDecelerate:(BOOL)decelerate; // Decelaration - (void)pageScrollViewWillBeginDecelerating:(HGPageScrollView *)scrollView; - (void)pageScrollViewDidEndDecelerating:(HGPageScrollView *)scrollView; // Called before the page scrolls into the center of the view. - (void)pageScrollView:(HGPageScrollView *)scrollView willScrollToPage:(HGPageView*)page atIndex:(NSInteger)index; // Called after the page scrolls into the center of the view. - (void)pageScrollView:(HGPageScrollView *)scrollView didScrollToPage:(HGPageView*)page atIndex:(NSInteger)index; // Called before the user changes the selection. - (void)pageScrollView:(HGPageScrollView *)scrollView willSelectPageAtIndex:(NSInteger)index; - (void)pageScrollView:(HGPageScrollView *)scrollView willDeselectPageAtIndex:(NSInteger)index; // Called after the user changes the selection. - (void)pageScrollView:(HGPageScrollView *)scrollView didSelectPageAtIndex:(NSInteger)index; - (void)pageScrollView:(HGPageScrollView *)scrollView didDeselectPageAtIndex:(NSInteger)index; @end
2011年11月16日水曜日 | Published in 情報, 情報/2011-11-20, 情報/開発/ツール | 2 コメント
| Published in | 0 コメント
NSArray *people = [Person findAll]; NSArray *peopleSorted = [Person findAllSortedByProperty:@"LastName" ascending:YES]; Person *person = [Person findFirstByAttribute:@"FirstName" withValue:@"Forrest"];
[[Person findAll] each:^(Person* p) {
NSLog(@"Found %@",p.name);
}];NSArray* fatherArray = [[Person findAll] map:^id(Person* p) {
return p.father;
}];
[fatherArray each:^(Person* p) {
NSLog(@"Found %@",p.name);
}];Person *myNewPersonInstance = [Person createEntity];
Person *p = ...; [p deleteEntity];
+ (void) performSaveDataOperationWithBlock:(CoreDataBlock)block; + (void) performSaveDataOperationInBackgroundWithBlock:(CoreDataBlock)block;
typedef void (^CoreDataBlock)(NSManagedObjectContext *);
| Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
@interface ELCImagePickerController : UINavigationController {
id delegate;
}
@property (nonatomic, assign) id delegate;
-(void)selectedAssets:(NSArray*)_assets;
-(void)cancelImagePicker;
@end
@protocol ELCImagePickerControllerDelegate
- (void)elcImagePickerController:(ELCImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSArray *)info;
- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker;
@interface ELCAlbumPickerController : UITableViewController {
NSMutableArray *assetGroups;
NSOperationQueue *queue;
id parent;
ALAssetsLibrary *library;
}
@property (nonatomic, assign) id parent;
@property (nonatomic, retain) NSMutableArray *assetGroups;
-(void)selectedAssets:(NSArray*)_assets;
@end2011年11月15日火曜日 | Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
| Published in 情報, 情報/2011-11-20, 情報/開発/チュートリアル | 0 コメント
imageView.frame = CGRectMake(10.0, 10.0, imageSize.width*1.2, imageSize.height);円形がこのように変形する。
| Published in 情報, 情報/2011-11-20, 情報/開発/iOS5, 情報/開発/チュートリアル | 0 コメント
2011年11月14日月曜日 | Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
| Published in 情報, 情報/2011-11-20, 情報/開発/iOS5 | 0 コメント
| カテゴリ | 用途 | ディレクトリ | バック アップ対象 |
| Critical Data | ユーザが作成するデータ または 再作成ができないデータ | Documents | ◯ |
| Cached Data | 再ダウンロード または 再作成が可能なデータ | Library/Caches | × |
| Temporary Data | 使用期間の短い一時的な データで保存が不要なデータ | tmp | × |
| Offline Data | オフライン時に 利用するデータ | Documents または Library/Private Documents かつ拡張属性付与 | ◯ |
#include <sys/xattr.h>
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}拡張属性が認識されるのは iOS5.0.1以降。それ以前は機能しない(つまりバックアップされる)。| Published in 情報, 情報/2011-11-20, 情報/開発/ライブラリ | 0 コメント
UIActionSheet *testSheet = [UIActionSheet sheetWithTitle:@"Please select one."];
[testSheet addButtonWithTitle:@"Zip" handler:^{ NSLog(@"Zip!"); }];
[testSheet addButtonWithTitle:@"Zap" handler:^{ NSLog(@"Zap!"); }];
[testSheet addButtonWithTitle:@"Zop" handler:^{ NSLog(@"Zop!"); }];
[testSheet setDestructiveButtonWithTitle:@"No!" handler:^{ NSLog(@"Fine!"); }];
[testSheet setCancelButtonWithTitle:nil handler:^{ NSLog(@"Never mind, then!"); }];
[testSheet showInView:self.view];[object performBlock:^(){
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
} afterDelay:0.5f];UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(id sender) {
NSLog(@"Single tap.");
} delay:0.18];
[self addGestureRecognizer:singleTap];| Published in 情報, 情報/2011-11-20, 情報/開発/デバッグ | 0 コメント