Hey everyone,
I posted this on the IRC channel, and it was suggested I posted it here too. I've been making an Adium plugin to interface with the contact list widget, and have got a bit stuck.
The link below is an excerpt of the code from the plugin. The contactDisplayName method works OK, but contactStatusList doesn't. I want to get the status of each AIListContact in the "contactList" array. Even getting the generic flags for Available/Idle/Away/Offline would be acceptable.
I have also tried to get the statusObjectForKey from it's containingObject, but no joy.
Once this is done, I will make a similar function to get the UID of each ListContact. Feel free to mock and/or suggest changes to this code. It's my first foray into objective-c.
http://paste.lisp.org/display/11478
Trying to get status string of AIListContact
- evands
- Cocoaforge Admin
- Posts: 3152
- Joined: Thu Dec 02, 2004 10:55 pm
- Location: Decatur, GA
- Contact:
You need to take a look at the AIListContact and AIListObject headers... -[AIListObject statusType] and -[AIListObject statusMessage] are relevant 
Side note: If you're re-creating the contact list, you might want to use -[AIListContact contactListStatusMessage], which returns an NSAttributedString (you can get the plain string with -[NSAttributedString string]).
Side note: If you're re-creating the contact list, you might want to use -[AIListContact contactListStatusMessage], which returns an NSAttributedString (you can get the plain string with -[NSAttributedString string]).
- evands
- Cocoaforge Admin
- Posts: 3152
- Joined: Thu Dec 02, 2004 10:55 pm
- Location: Decatur, GA
- Contact:
What is contactList? Where are you getting it? What are the objects within it?
Use NSLog() within your methods to determine what you're messaging before you message it; look at what you're about to message, then check the code to see if that's reasonable.
within your loop, for example
Use NSLog() within your methods to determine what you're messaging before you message it; look at what you're about to message, then check the code to see if that's reasonable.
Code: Select all
NSLog(@"This object is %@",[contactList objectAtIndex:i]);
contactList is an array containing AIListContact objects. NSLog output confirms this.
I'm still not seeing why I can't send some messages to these objects.
For example:
both work OK (where "[contactList objectAtIndex:i]" is an AIListContact object). The displayName method comes from the AIListContact object, and UID comes from AIListObject.
But...
don't work. Both cause the log messages to read "(null)".
I realise I'm sending these messages to a ListContact and not ListObject, but the UID message above works OK like this. I don't understand what I'm doing wrong. Do the AIListContacts need to somehow be turned into AIListObjects or something?
I'm still not seeing why I can't send some messages to these objects.
For example:
Code: Select all
[contacts addObject:[NSString stringWithString:[[contactList objectAtIndex:i] displayName]]];
and
[contacts addObject:[NSString stringWithString:[[contactList objectAtIndex:i] UID]]];
But...
Code: Select all
[contacts addObject:[NSString stringWithString:[[contactList objectAtIndex:i] statusName]]];
and
[contacts addObject:[NSString stringWithString:[[contactList objectAtIndex:i] statusMessage]]];
I realise I'm sending these messages to a ListContact and not ListObject, but the UID message above works OK like this. I don't understand what I'm doing wrong. Do the AIListContacts need to somehow be turned into AIListObjects or something?
- evands
- Cocoaforge Admin
- Posts: 3152
- Joined: Thu Dec 02, 2004 10:55 pm
- Location: Decatur, GA
- Contact:
Please svn update and check the documentation I've added to AIListObject.m related to the status methods; hopefully it was clear up some confusion. The methods were previously undocumented, which is Wrong.
And in answer to your last question: AIListContacts are AIListObjects. If you look at the AIListContact.h header file, you see
which indicates that AIListContact inherits from its superclass AIListObject.
And in answer to your last question: AIListContacts are AIListObjects. If you look at the AIListContact.h header file, you see
Code: Select all
@interface AIListContact : AIListObject
Thanks for clearing up the docs Evan.
I've got the plugin to return an array of strings for statusType by using:
(where contactList is an array of AIListContacts)
I've not yet spent much time finding out why, but this always returns "Generic Available" for offline contacts. I'm probably doing something funny though, so will have a proper look later.
Thanks again for updating the documentation for those methods.
I've got the plugin to return an array of strings for statusType by using:
Code: Select all
[NSString stringWithString:[[adium statusController] defaultStatusNameForType:[[contactList objectAtIndex:i] statusType]]]I've not yet spent much time finding out why, but this always returns "Generic Available" for offline contacts. I'm probably doing something funny though, so will have a proper look later.
Thanks again for updating the documentation for those methods.
