2

I'm getting the below warning on iOS6, when creating an ABAddressBook object. I'm using it like this:

ABAddressBook ab = new ABAddressBook ();

result:

Warning CS0618: `MonoTouch.AddressBook.ABAddressBook.ABAddressBook()' is obsolete: `Use static Create method in iOS 6.0' (CS0618)

How should I use the static method as mentioned above?

Brian
  • 14,610
  • 7
  • 35
  • 43
Pirate
  • 71
  • 1
  • 10

1 Answers1

5

The most important thing, when you see an [Obsolete] warning about deprecated API is to compare it with your application target.

E.g. if you want your application to work on iOS 5.1 (so it executes on an original iPad) then you might not be able to use the new API (e.g. Create in this case).

If you're only targeting iOS 6 (and later) then you can stop using deprecated API.

OTOH it does not mean the old code does not work. It still does because Apple wants you to create applications that works across several versions of iOS. So you have time to remove them from your application (before Apple removes them from their library).

how to use the static method as mentioned above ?

Here's how to use the new API:

NSError error;
ABAddressBook ab = ABAddressBook.Create (out error);
if (error != null)
    Console.WriteLine ("uho, deal with error");
poupou
  • 43,413
  • 6
  • 77
  • 174