2013-12-13 40 views

回答

3

請閱讀更改說明它清楚地說,使用init方法

編輯:因爲它在無限循環中使用[super init]而不是[self init]

- (id)init 
{ 
    // return [self init]; 
     return [super init]; 
} 
+1

;訪問不暢。 – Kalpesh

+0

取決於你在做什麼。如果你重寫自定義類,你應該使用[super init];否則你應該使用[[CustomIOS7AlertView alloc] init] – muffe

+0

是啊我2,似乎進入了一個無限循環。可能是這個自定義類中的另一個問題,雖然 – Mathijs

1
#pragma clang diagnostic push 
#pragma clang diagnostic ignored "-Wdeprecated-declarations" 
- (void) methodUsingDeprecatedStuff { 
    //use deprecated stuff 
} 
#pragma clang diagnostic pop 

這應該抑制它。

1

那麼,類的* .h告訴你該怎麼做

/*! DEPRECATED:在不傳遞父視圖的情況下使用[CustomIOS7AlertView init]方法。 */

所以,如果你重寫自定義類只使用

[self init]; 

使用別的

[[CustomIOS7AlertView alloc] init] 
+0

使用[self init]後;有訪問不好 – Kalpesh

+0

取決於你在做什麼。如果你重寫自定義類,你應該使用[super init];否則,你應該在[self init]之後使用[[CustomIOS7AlertView alloc] init] – muffe

3

看起來開發人員將此標記爲已棄用,並建議使用init方法。您可以編輯第三方庫以刪除此屬性或將其禁用。也許將initWithParentView的內容移動到init中會更好地修復該庫。

/*! 
DEPRECATED: Use the [CustomIOS7AlertView init] method without passing a parent view. 
*/ 
- (id)initWithParentView: (UIView *)_parentView __attribute__ ((deprecated));