Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

Where to place my Widget's resourse file?

Author Message
terroristwin



Joined: 21 Mar 2005
Posts: 7
Location: ShangHai,China

Posted: Sun Mar 27, 2005 - 10:17 am    Post subject: Imported from The Dashboader Reply with quote

I am working on a Widget, It need to store a lot of informations like AddressBook Widget. I want to write the information into a file and read it when needed. But I don't want to install a program like AddressBook. I just want to handle the file read and write inside the Widget bundle using a Cocoa plugin, and also place the resourse file inside the Widget.

How can I do this? I am really new for Mac technolegy...
Thanks!
_________________
Terry
View user's profile Send private message Send e-mail Visit poster's website MSN MessengerWidgets
iremembercliford



Joined: 27 Mar 2005
Posts: 32

Posted: Thu Mar 31, 2005 - 12:42 am    Post subject: Reply with quote

The AddressBook widget does not store any of that information, it reads from a global addressbook ( [ABAddressBook sharedAddressBook] ). Storing resources is all handled by the bundle when creating a plugin. If you create a bundle, then just drag anything you need (pictures, text files, etc) into the resources folder in XCode. Then you can access then directly, otherwise, you will need to locate them using NSBundle. If you don't know Cocoa, I would recommend learning it first, or at least enough that you feel comfortable writing the plugin for a widget.

Also it would help it you could let us know what exactly you are trying to include in the bundle. Then I could better help you.
View user's profile Send private message Send e-mail Widgets
terroristwin



Joined: 21 Mar 2005
Posts: 7
Location: ShangHai,China

Posted: Thu Mar 31, 2005 - 4:47 am    Post subject: Reply with quote

I have already tried to place the file inside the bundle, and use NSBundle to read it. But every time I read the file inside the bundle, the Widget will crash. I think Dashboard do not surpport to do so.
_________________
Terry
View user's profile Send private message Send e-mail Visit poster's website MSN MessengerWidgets
iremembercliford



Joined: 27 Mar 2005
Posts: 32

Posted: Thu Mar 31, 2005 - 10:16 am    Post subject: Reply with quote

What kind of file is it, and how are you using it?

Some code would help too.
View user's profile Send private message Send e-mail Widgets
iremembercliford



Joined: 27 Mar 2005
Posts: 32

Posted: Mon Apr 18, 2005 - 4:26 pm    Post subject: Reply with quote

I'm sorry for taking so long to get back to you on this. The answer is just a simple change in the call to NSBundle.

Since Dashboard is now a part of dock.app, a call to [NSBundle mainBundle] will result in the bundle for the dashboard part of the dock.

To get to the resources in your Resouce folder of your bundle do the following:

- Make sure you have a bundle identifier. In your plist you should have a line like:
<key>CFBundleIdentifier</key>
<string>com.apple.bashPlugin.plugin</string>

- Place the resource in the resources folder of your XCode project

- Now you can access the file with NSBundle. Here is an example from my project:

NSString *bundlepath = [[NSBundle bundleWithIdentifier:@"com.apple.bashPlugin.plugin"] resourcePath];
NSString *fullpath = [bundlepath stringByAppendingString:@"/ptycreate"];

Hope this helps anyone who was trying to do this.
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group