使用非弃用的64位代码替换CMNewProfileSearch [英] Replacing CMNewProfileSearch with non-deprecated, 64-bit code

查看:229
本文介绍了使用非弃用的64位代码替换CMNewProfileSearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有现有的代码,使用 CMNewProfileSearch 找到然后迭代在系统上的颜色配置文件获取他们的名字和完整的路径。不幸的是,在Mac OS X 10.5中不推荐使用 CMNewProfileSearch ,并且在编译64位应用程序时也不可用。



在阅读ColorSync Manager 2.5 Reference中,似乎使用 CMIterateColorSyncFolder 函数来迭代已安装的颜色配置文件的新方法。


  1. 这是真的吗?

  2. 任何人都有任何示例代码?

谢谢。

解决方案


  1. 是的。如您所示, ColorSync管理器参考说,以下:



    CMNewProfileSearch函数没有充分利用优化的配置文件
    搜索从ColorSync版本2.5开始。

  2. 方法来做到这一点。


  3. Apple's ImageApp示例代码


编辑:我修改了代码示例以删除 NewCMProfileIterateUPP DisposeCMProfileIterateUPP

  
//通过可用配置文件迭代期间调用的配置文件描述的回调例程
//。
//
static OSErr profileIterate(CMProfileIterateData * info,void * refCon)
{
NSMutableArray * array =(NSMutableArray *)refCon;

个人资料* prof = [个人资料profileWithIterateData:info];
if(prof)
[array addObject:prof];

return noErr;
}

//返回所有配置文件的数组
//
+(NSArray *)arrayOfAllProfiles
{
NSMutableArray * profs = [[NSMutableArray arrayWithCapacity:0] retain];
CMIterateColorSyncFolder(profileIterate,NULL,0L,profs);
return(NSArray *)profs;
}



原来不需要 NewCMProfileIterateUPP DisposeCMProfileIterateUPP ,所以他们没有被任何替换,就我所知。相反,您可以使用与上面 profileIterate 匹配的签名来定义回调函数。然后,您可以直接将回调函数传递给 CMIterateColorSyncFolder



=http://developer.apple.com/SampleCode/ImageApp/index.html =nofollow noreferrer> ImageApp 在Mac OS X 10.5上它可以正常工作。


I have existing code that uses CMNewProfileSearch to find then iterate over the color profiles on the system getting their names and full paths. Unfortunately, CMNewProfileSearch is deprecated in Mac OS X 10.5 and is also unavailable when compiling a 64-bit application.

In reading the ColorSync Manager 2.5 Reference, it seems like the new way to iterate over installed color profiles is to use the CMIterateColorSyncFolder function.

  1. Is that true?
  2. Is there a Cocoa way to do what I want instead?
  3. Anybody got any sample code?

Thanks.

解决方案

  1. Yes. As you indicated, the ColorSync Manager Reference says the following:

    The CMNewProfileSearch function does not take full advantage of the optimized profile searching available starting with ColorSync version 2.5. Use CMIterateColorSyncFolder instead.

  2. CMIterateColorSyncFolder is the official way to do this. Besides, it's also the optimized way.

  3. From Apple's ImageApp sample code:

EDIT: I've modified the code sample to remove NewCMProfileIterateUPP and DisposeCMProfileIterateUPP.


    // Callback routine with a description of a profile that is 
    // called during an iteration through the available profiles.
    //
    static OSErr profileIterate (CMProfileIterateData *info, void *refCon)
    {
        NSMutableArray* array = (NSMutableArray*) refCon;

        Profile* prof = [Profile profileWithIterateData:info];
        if (prof)
            [array addObject:prof];

        return noErr;
    }

    // return an array of all profiles
    //
    + (NSArray*) arrayOfAllProfiles
    {
        NSMutableArray* profs=[[NSMutableArray arrayWithCapacity:0] retain];
        CMIterateColorSyncFolder(profileIterate, NULL, 0L, profs);
        return (NSArray*)profs;
    }

It turns out that don't need NewCMProfileIterateUPP and DisposeCMProfileIterateUPP so they haven't been replaced with anything, as far as I can tell. Instead, you can define the callback function with a signature that matches profileIterate, above. You can then just pass the callback function directly to CMIterateColorSyncFolder.

I've tested my changes in ImageApp on Mac OS X 10.5 it it works as expected.

这篇关于使用非弃用的64位代码替换CMNewProfileSearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆