Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary using call method




However, I have a solution that might be good for you. It is attached. It shows how to use some calls of NSDictionary. If you need others, they should be quite easy to add.


Thanks for you kind example code. But your sample is not enough for me. Because your sample can not cheange the value of existing entry. I will give up using NSMutableArray. I will use a following handmade code instead of NSMutabelDictionary.

property keyList : {}
property valueList : {}

on getValue given forKey:theKey
	set theValue to missing value
	repeat with ith from 1 to length of keyList
		if item ith of keyList is theKey then
			set theValue to item ith of valueList
			exit repeat
		end if
	end repeat
	return theValue
end getValue

on setValue given forKey:theKey, withValue:theValue
	if theKey is in keyList then
		repeat with ith from 1 to length of keyList
			if item ith of keyList is theKey then
				set item ith of valueList to theValue
				exit repeat
			end if
		end repeat
	else
		set end of keyList to theKey
		set end of valueList to theValue
	end if
end setValue

on removeItem given forKey:theKey
if theKey is in keyList then
set nList to length of keyList
repeat with ith from 1 to nList
if theKey is item ith of keyList then
set keyList to deleteNthItem given atIndex:ith, listLength:nList, fromList:keyList
set valueList to deleteNthItem given atIndex:ith, listLength:nList, fromList:valueList
exit repeat
end if
end repeat
return true
else
return false
end if
end removeItem



_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-studio mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.