Re: NSArrays comparison
Re: NSArrays comparison
- Subject: Re: NSArrays comparison
- From: Ricky Sharp <email@hidden>
- Date: Sat, 4 Mar 2006 15:44:30 -0600
On Mar 4, 2006, at 3:10 PM, XTAL wrote:
I'm building a bus analyzer for an in-car CD-changer, and I store
the binary messages in NSArrays as 'char' NSValues. now my question
would be: can I store "wildcards" in NSArrays, so that the compare
function can handle them?
a short example, why I need this:
18 0A 68 39 00 02 00 3F 00 01 01 7E
this message contains parameters and a checksum, which change all
the time. so I'd like to store an array with wildcards:
XX 0A XX 39 00 02 00 3F 00 XX XX XX
my goal would be, to store such arrays, and compare them to
incoming messages, so I can easily recognize commands. is this
possible? (this would be much more easier than to examine the byte
values one by one.)
If I were doing this, I'd create a "Message" object that would do
whatever was needed to manage messages. Among other things, one API
on it would be a comparison method.
Assuming each message is 12-bytes, I'd just create a struct to store
the individual bytes. Perhaps using a SInt16 for each entry so that
you could store 00..FF along with a -1 (to denote a wildcard).
A class method could then be implemented to provide you a string for
display purposes (assuming that you really need the message to be in
string form on ocassion).
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden