Mathijs
Mathijs

Reputation: 1268

Suppress warning for deprecated method when there's no alternative for it

I've implemented this custom class in a project: https://github.com/wimagguc/ios-custom-alertview

But Xcode gives a warning that the "initWithParentView" has been deprecated.

- (id)init
{
    return [self initWithParentView:NULL];
}

I haven't been able to find a alternative to this method, and the class works splendid. Can someone tell me how to suppress this warning OR tell me an alternative to "initWithParentView"?

Upvotes: 1

Views: 779

Answers (4)

Suhit Patil
Suhit Patil

Reputation: 12023

please read the change notes it clearly says use init method

Edit: as it's going in the infinite loop use [super init] instead of [self init]

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

Upvotes: 3

muffe
muffe

Reputation: 2295

Well, the *.h of the class tells you what to do

/*! DEPRECATED: Use the [CustomIOS7AlertView init] method without passing a parent view. */

So if you're overriding the custom class just use

[self init];

else use

[[CustomIOS7AlertView alloc] init]

Upvotes: 1

Neonkoala
Neonkoala

Reputation: 392

It looks like the developer marked this as deprecated and suggests using the init method. You can edit the 3rd party library to remove this attribute or suppress it. Perhaps moving the contents of initWithParentView into init would be a better fix of the library.

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

Upvotes: 3

Andrew
Andrew

Reputation: 3241

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

This should suppress it.

Upvotes: 1

Related Questions