simplify mobiledevice.c -> rename to mobiledevice.m and use NSSttring instead of CFString and ARC

saves about 100 lines of code and makes string deallocation a bit more safe 
I didn’t see that unregister_device_notification does exit(code) , so my corrected version will be
static void get_udid(struct am_device *device)
{
  NSString* udid = (__bridge NSString*) AMDeviceCopyDeviceIdentifier(device);
  // print UDID to stdout
  if (udid != nil)
  {
    printfNS(@"%@\n", udid);
  }

  unregister_device_notification(udid==nil? 1: 0);
}
Regards, Leo

On 21.10.2014, at 22:37, Leo Schubert <leopatras@googlemail.com> wrote:

> Mario, If you refer to
> void get_udid(struct am_device *device)
> {
>   char *udid = create_cstr_from_cfstring(AMDeviceCopyDeviceIdentifier(device));
> 
>   if (udid == NULL)
>   {
>     unregister_device_notification(1);
>   }
> 
>   // print UDID to stdout
>   printf(“%s\n”, idid); //leo: “(null)” is printed in the NULL case
> 
>   free(udid);
>   unregister_device_notification(0); //leo: unregister_device_notification is called twice if udid==NULL, is this intended ?
> }
> 
> my replacement is now
> static void get_udid(struct am_device *device)
> {
>   NSString* udid = (__bridge NSString*) AMDeviceCopyDeviceIdentifier(device);
>   // print UDID to stdout
>   printfNS(@"%@\n", udid==nil ? @“(null)” : udid); //was “(nil)” before in the NULL case.
>   unregister_device_notification(udid==nil? 1: 0);
> }
> 
> Ok for you ?
> Regards, Leo
> 
> On 20.10.2014, at 08:33, Mário Freitas <notifications@github.com> wrote:
> 
>> In mobiledevice.m:
>> 
>> > +  ASSERT_OR_EXIT(AMDeviceIsPaired(device), "!AMDeviceIsPaired\n");
>> > +  ASSERT_OR_EXIT(!AMDeviceValidatePairing(device), "!AMDeviceValidatePairing\n");
>> > +  ASSERT_OR_EXIT(!AMDeviceStartSession(device), "!AMDeviceStartSession\n");
>> > +}
>> > +
>> > +static NSString* get_bundle_id(const char *app_path)
>> > +{
>> > +  NSString* path=[NSString stringWithUTF8String:app_path];
>> > +  path=[path stringByAppendingPathComponent:@"Info.plist"];
>> > +  NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
>> > +  return dict[@"CFBundleIdentifier"];
>> > +}
>> > +
>> > +static void get_udid(struct am_device *device)
>> > +{
>> > +  NSString* udid = (__bridge NSString*) AMDeviceCopyDeviceIdentifier(device);
>> Because i think "(nil)" is not a "standard" way to print signal an error (especially if it is printed out to stdout). 
>> Furthermore, in order to maintain compatibility with the previous version, nothing should be printed, and unregister_device_notification(1) should be called.
>> 
>> —
>> Reply to this email directly or view it on GitHub.
>> 
>