>> 
>>> Is the IOObjectRelease() right or wrong ?
>>      I’m not entirely sure since I can’t find the docs for 
>> IOServicePortFromCGDisplayID.
> 
> Given that the code fragment shows it as a message being sent to “self”, this 
> looks like Gabriel’s own method. By the standard Obj-C clang naming 
> conventions, this should return a non-owning (+0) reference, so it should not 
> be released without being explicitly retained.
> 
> My guess is that it actually returns a +1 reference, but uses a non-standard 
> naming convention. In that case, the code is correct as written (although 
> unclear because it doesn’t follow the naming conventions).
> 

Sorry again for the incomplete question.

This is what my function IOServicePortFromCGDisplayID essentially does:

- (io_service_t) IOServicePortFromCGDisplayID: (CGDirectDisplayID) displayID
{
    io_iterator_t iter;
    io_service_t serv, servicePort = 0;
   kern_return_t err = IOServiceGetMatchingServices( kIOMasterPortDefault, 
matching, & iter );
    
    while ( (serv = IOIteratorNext(iter)) != 0 )
    {
       ... check some criteria
       if ( it is not the right display )
         continue; 

        servicePort = serv;
        CFRelease(displayInfo);
        break;
    }
    
    IOObjectRelease(iter);
    return servicePort;
}

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to