2012-02-26 8 views
0

'をしてみてください'、私はエラーを取得する前に:予想識別子または '(' 'してみてください' Objective-Cの前エラー:予想される識別子または '(' 私は@try @catchを使用する場合はObjective-Cの

@implementation BannerView 
@synthesize timer; 

@synthesize _responceInfo; 
@synthesize recivedData; 

@try { 
NSString* const _mainUrl = 
@"http://www.admobilapp.com/view.php?place_id=15&country_id=112&sex=3&rand=0.7858213884755969&gsmOperator="; 
} 
@catch (NSException * e) { 
    NSLog(@"Exception: %@", e); 
} 
@finally { 
    NSLog(@"finally"); 
} 

NSString*const _ImagePath= @"\"image\":"; 
NSString*const _ImageClickUrl= @"\"link\":"; 
NSString*const _imagerotation = @"\"rotation\":"; 

をそれを修正する方法

エラー:?期待識別子または「(」固定Objective-Cのを、「してみてください」、しかし、私は、アプリケーションを実行する場合、今、私は別のエラーを持って前に、 とアプリがクラッシュです

2012-。 02-27 00:28:02.794最後に[8409:9203] 2012-02-27 00:28:02.818 Clicky [8409:9203] *キャッチされない例外によりにアプリを終了 'NSRangeException'、理由: ' - [NSCFString substringFromIndex:]:範囲外の範囲またはインデックス' * *最初のスローでスタックを呼び出します。 ( 0 CoreFoundationの0x00db1be9 exceptionPreprocess + 185 1 libobjc.A。dylib 0x00f065c2 objc_exception_throw + 47 2 CoreFoundationの0x00d6a628 + [NSExceptionレイズ:フォーマット:引数:] + 136 3 CoreFoundationのを0x00d6a59a + [NSExceptionレイズ:フォーマット:] + 58 4ファンデーション0x000250de - [NSStringのsubstringFromIndex:] + 133 5 Clicky 0x00003232 - [BannerView ExtractStringKeyValue:] + 123 6 Clicky 0x000031b1 - [BannerView ExtractImageUrl] + 48 7 Clicky 0x00003739 - [BannerViewリフレッシュ] + 59 8 Clicky 0x00003805 - [BannerView initWithFrame:] + 157 9のUIKit 0x0049fce5 + [UIButton buttonWithType:] + 1373 10 Clicky 0x00002e6a - [例viewDidLoad] + 51 11 UIKit 0x0036865e - [UIViewControll ER図] + 179 12のUIKit 0x0037b230 - [UITabBarController transitionFromViewController:toViewController:遷移:shouldSetSelected:] + 120 13のUIKit 0x00379d86 - [UITabBarController transitionFromViewController:toViewController:] + 64 14のUIKit 0x0037bb7e - [UITabBarController _setSelectedViewController:] + 263 15のUIKit 0x0037b9ed - [UITabBarController _tabBarItemClicked:] + 352 16のUIKit 0x002baa6e - [のUIApplication sendAction:に:から:forEvent:] + 119 17のUIKit 0x004b81f2 - [UITabBar _sendAction:withEvent:] + 422 18のUIKit 0x002baa6e - [のUIApplication19 UIKit 0x003491b5 - [UIControl sendAction:to:forEvent:] + 67 20 UIKitの0x0034b647 - [Uicontrolの(内部)_sendActionsForEvents:withEvent:] + 527 21のUIKit 0x0034916c - [するuicontrol sendActionsForControlEvents:] + 49 22のUIKit 0x002baa6e - [のUIApplication sendAction:に:から:forEvent:] + 119 23のUIKit 0x003491b5 - [UicontrolのsendAction:全forEvent:] + 67 24のUIKit 0x0034b647 - [Uicontrolの(内部)_sendActionsForEvents:withEvent:] + 527 25のUIKit 0x0034a1f4 - [するuicontrol touchesEnded:withEvent:] + 458 26のUIKit 0x002df0d1 - [UIWindow _sendTouchesForEvent :] + 567 27 UIKit 0x002c037a - [UIApplication sendEvent:] + 447 28 UIKit 0x002c5732 _UIApplicationHandleEvent + 7576 29 GraphicsServices 0x016e7a36 PurpleEventCa llback + 1550 30 CoreFoundationの0x00d93064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 52 31 CoreFoundationの0x00cf36f7 __CFRunLoopDoSource1 + 215 32 CoreFoundationの0x00cf0983 __CFRunLoopRun + 979 33 CoreFoundationの0x00cf0240 CFRunLoopRunSpecific + 208 34 CoreFoundationの0x00cf0161 CFRunLoopRunInMode + 97 35 GraphicsServices 0x016e6268 GSEventRunModal + 217 36 GraphicsServices 0x016e632d GSEventRun + 115 37のUIKit 0x002c942e UIApplicationMain + 1160 38 Clicky 0x00002840メイン+ 102 39 Clickyが開始0x000027d1 + 53 ) 例外をスローすると呼ばれる終了する

@try @catchは機能しません。 :(。あなたは、メソッドの外でコードを書くことはできません

+2

郵便、この前のコード。エラーがあります – sch

+2

このコードはメソッドにありますか?それとも、実装自体にすべてがぶら下がっていますか? –

+0

@Peter MIは同じことを考えました:) – Max

答えて

3

あなたはメソッド本体の外@try/@catch/@finallyを使用することはできません。静的な文字列を割り当てると、とにかく失敗することはできません。

関連する問題