本アプリは広告やアナリティクスなどを導入していないので,データを収集していません.
※ご不明な点があれば,お気軽にお問い合わせください.
Read more
※ご不明な点があれば,お気軽にお問い合わせください.
UIAlertView *alertView_;ライブラリはここに置いています.
alertView_ = [[UIAlertView alloc] initWithTitle:nil
message:@"message"
completion:^(UIAlertView *alertView, NSInteger buttonIndex){
// do something
}
cancelButtonTitle:@"NO"
otherButtonTitles:@"YES",nil];
[alertView_ show];
[MyTimer.h]つぎに,メソッドファイルにて,そのデリゲートを好きなタイミングで呼び出す.
#import < foundation / foundation.h >
@class MyTimer;
@protocol MyTimerDelegate
@optional // オプション
-(void)didMyTimerCounted:(MyTimer *)myTimer;
@required // 必須
-(void)didMyTimerFinished:(MyTimer *)myTimer;
@end
@interface MyTimer : NSObject
@property NSInteger counter;
@property id < MyTimerDelegate > delegate;-(void)countDown:(NSInteger)time;
@end
[MyTimer.m]自作デリゲートの実装のこれで終わり.ほかのデリゲートと同様に使えばOK.
#import "MyTimer.h"
@implementation MyTimer
-(void)countDown:(NSInteger)time
{
self.counter = time;
do{
self.counter--;
[self.delegate didMyTimerCounted:self];
}while ( self.counter > 0 );
[self.delegate didMyTimerFinished:self];
}
@end
[MEViewController.h]
#import < UIKit / UIKit.h >
#import "MyTimer.h"
@interface MEViewController : UIViewController < MyTimerDelegate >
{
MyTimer *myTimer_;
}
@end
[MEViewController.m]
#import "MEViewController.h"
@implementation MEViewController
- (void)viewDidLoad
{
[super viewDidLoad];
myTimer_ = [[MyTimer alloc] init];
myTimer_.delegate = self;
[myTimer_ countDown:20];
}
-(void)dealloc
{
myTimer_.delegate = nil;
}
-(void)didMyTimerCounted:(MyTimer *)myTimer
{
NSLog(@"%s", __func__);
NSLog(@"counter = %d", myTimer.counter);
}
-(void)didMyTimerFinished:(MyTimer *)myTimer
{
NSLog(@"%s", __func__);
NSLog(@"counter = %d", myTimer.counter);
}
@end
@interface MyViewController : UIViewController
-(BOOL)hogehoge:(NSError **)error;
@end
@implementation MyViewController
-(BOOL)hogehoge:(NSError **)error
{
if( 問題が起こったとき )
{
if( error )
{
NSMutableDictionary* errDetails = [NSMutableDictionary dictionary];
[errDetails setValue:@"エラーの原因など" forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:@"world" code:200 userInfo:errDetails];
}
return NO;
}
return YES;
}
-(void)main
{
NSError *err = nil;
if ( [self hogehoge:&err] == NO)
{
NSLog(@"%@", [err localizedDescription]);
}
}
@end
脱アカデミック(研究・教師)をしたフリーランスのプログラマ.iPhoneアプリの企画,開発,デザイン,グラフィック,サウンド,テスト,デバッグ,サポート,広報をやっています.要望・提案・依頼・苦情・雇用・求婚・養子縁組・財産分与あれば連絡ください.
Copyright 2009 mthr Blog+ | designed by Bloggets
Icons by Dryicons

