Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iPhoneアプリの通信エラー処理を考える

ninjinkun
January 26, 2012

 iPhoneアプリの通信エラー処理を考える

iPhoneアプリの通信エラー処理についての考察と実装。サンプルはこちら https://github.com/ninjinkun/AlertResume

ninjinkun

January 26, 2012
Tweet

More Decks by ninjinkun

Other Decks in Technology

Transcript

  1. Path έʔεελσΟ • ࣦഊͯ͠΋੒ޭͨ͠Α͏ʹݟ͍ͤͯΔ • ޙ͔Β௨৴͕ܨ͕Ε͹࠶౓ૹ৴ʢࣗಈʣ • ୯ͳΔPOST / GETͰ͸ͳ͘σʔλΛಉظ͍ͯ͠Δ(?)

    • ϢʔβʔʹΤϥʔΛҙࣝͤ͞ͳ͍ • দϓϥϯ • ͦͷ൓໘ૹ৴͕׬͍ྃͯ͠ͳ͍͜ͱʹ͸ؾ͔ͮͳ͍…
  2. Τϥʔͷදࣔ ࣮૷ NSArray *buttons = [NSArray arrayWithObjects:@"Ωϟϯηϧ", @"࠶ࢼߦ͢Δ", nil]; NSDictionary

    *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: @"ωοτϫʔΫΤϥʔ͕ൃੜ͠·ͨ͠", NSLocalizedDescriptionKey, @”ωοτϫʔΫʹ઀ଓͰ͖·ͤΜ”, NSLocalizedFailureReasonErrorKey, @"઀ଓΛ֬ೝͯ͠…", NSLocalizedRecoverySuggestionErrorKey, buttons, NSLocalizedRecoveryOptionsErrorKey, nil]; NSError*error = [NSError errorWithDomain:@"com.hoge.fuga" code:100 userInfo:userInfo];
  3. Τϥʔͷදࣔ ࣮૷ • UIAlertViewʹ৯Θͤͯදࣔ͢Δ @implementation UIAlertView (NSErrorAddition) -(id)initWithError:(NSError *)error {

    self = [super init]; if (self) { self.title = [error localizedDescription]; self.message = [[NSArray arrayWithObjects:[error localizedFailureReason], [error localizedRecoverySuggestion], nil] componentsJoinedByString:@"\n"]; NSArray* optionTitles = [error localizedRecoveryOptions]; for (NSString *title in optionTitles) { [self addButtonWithTitle:title]; } } return self; } @end
  4. ·ͱΊ • ௨৴Τϥʔॲཧͷํ๏ʹ͍ͭͯߟ࡯ͨ͠ • ௨৴Τϥʔ͸ਖ਼ৗܥͷҰ෦ͱͯ͠ߟ͑Α͏ • ༷ʑͳΞϓϦͷέʔεΛ؍࡯ͨ͠ • Path͸͕Μ͹͍ͬͯΔ •

    ௨৴ΤϥʔॲཧΛ࣮૷ͯ͠Έͨ • UIAlertView • ϨδϡʔϜॲཧ2छྨ • େม͚ͩͲ͕Μ͹Γ·͠ΐ͏