How to load a text-resource from a bundle (Plugin)
Christiaan Hofman
cmhofman at gmail.com
Sat Dec 29 12:19:50 PST 2007
So does your bundle have the proper layout for a macosx bundle,
including the identifier in the info.plist?
Christiaan
On 29 Dec 2007, at 4:28 PM, Aya Koshigaya wrote:
> Hi,
>
> thanks for your answers :)
>
>> You might want to retry using the
>> [NSBundle bundleForClass:NSClassFromString(@"YourClassName")]
>
>
> And what should I use as ClassName? I don't have any ObjC Classes..
> only normal C-Classes.. can I use these too?
>
>
>> +[NSBundle mainBundle] gives you the bundle of the app in which
>> your plugin is loaded, so that indeed won't work. You should use
>> either +[NSBundle bundleWithIdentifier:] or +[NSBundle
>> bundleForClass:] to get the bundle of your plugin.
>
>
> I tried these two allready,both weren't working for me (see the
> original mail, there I said why I had problems with these two)
>
> Regards,
> Aya
>
>
> On Dec 29, 2007, at 11:46, scott little wrote:
>
>> Aya,
>>
>> You might want to retry using the
>>
>> [NSBundle bundleForClass:NSClassFromString(@"YourClassName")]
>>
>> This might work for you,
>>
>> scott
>> --
>> “To announce there must be no criticism of the President, and to
>> stand by the President, right or wrong, is not only unpatriotic
>> and servile, it is morally treasonous to the American public.”
>> President Theodore Roosevelt
>> --
>> scott little
>> slittle at free.fr
>> --
>> sadly no music right now: iTunes is Stopped
>>
>>
>>
>> On 29/12/2007, at 02:46, Aya Koshigaya wrote:
>>
>>> Hi,
>>>
>>> I have developed a plugin for Autodesk Maya for Windows. I now
>>> want to port this plugin to OSX.. and here i have some problems :(
>>>
>>> I opened one of the Maya-ExamplePlugins in xCode and then just
>>> replaced all the files with my own. So far, no problem.. but I'm
>>> using some resources that I included to my plugin.
>>>
>>> In Windows I used the WinAPI functions "FindResource" and
>>> "LoadResource".. and here's the problem, I have no idea how to
>>> port this to osx.
>>>
>>> In xCode I added my Resource (It's a textfile "data.txt") and put
>>> it in the Resources-Folder so it will be copied to the bundle
>>> when building.
>>>
>>> I now tried to load the file via Cocoa:
>>> NSString *nsResource = [[NSBundle mainBundle]
>>> pathForResource:@"data" ofType:@"txt"];
>>>
>>> But the resource wasn't found, I found out, the problem is
>>> "mainBundle" is the Maya-Bundle, not my plugin...
>>>
>>>
>>> After this I tried to find my bundle, but with no result.. :(
>>> When I use this:
>>> [NSBundle bundleForClass:[self class]];
>>>
>>> I get a compile-error that says "self is undeclared", because my
>>> plugin is still written in C, not ObjC... and I'm using the ObjC
>>> functions inside my normal C-functions = no self.
>>>
>>> Next try was:
>>> [NSBundle bundleWithIdentifier:@"de.koshigaya.test"];
>>>
>>> the result was NULL.. no bundle with this identifier was found :(
>>>
>>> As last thing I tried to list ALL bundles and see if my own one
>>> is found with this:
>>>
>>> NSArray *bundles = [NSBundle allBundles];
>>> for (int i = 0; i < [bundles count]; i++) {
>>> NSBundle *b = [bundles objectAtIndex:i];
>>> NSString *vident = [b bundleIdentifier];
>>> printOut([vident UTF8String]);
>>> }
>>>
>>> and... It only listed ONE bundle.. the same as "mainBundle".. ->
>>> com.alias.Maya.2008
>>>
>>> So... no I have no idea what to do more.. I'm totally helpless..
>>> Maybe Maya isn't realy "loading" my Bundle..? I mean, maybe Maya
>>> uses a way to load the bundle so it's not registered or
>>> something.. don't know.. :/
>>>
>>> Does anyone know what I can do? Help...
>>>
>>> Kind regards,
>>> Aya
>>> _______________________________________________
>>> MacOSX-dev mailing list
>>> MacOSX-dev at omnigroup.com
>>> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>>>
>>
>
> _______________________________________________
> MacOSX-dev mailing list
> MacOSX-dev at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
More information about the MacOSX-dev
mailing list