after some thought, i realized that it would be simpler to just send an
array of numbers, decode the numbers with some bit math and avoid the nested
structure problem.



On Fri, Jul 2, 2010 at 2:47 AM, fsk <fsko...@gmail.com> wrote:

>
>
> ---------- Forwarded message ----------
> From: fsk <fsko...@gmail.com>
> Date: Fri, Jul 2, 2010 at 2:46 AM
> Subject: Re: arrays of dictionaries
> To: Christopher Wright <christopher_wri...@apple.com>
>
>
> i am aware of this issue. but im not so sure i can tackle it in the most
> appropriate manner. the code i posted was the code with which i noticed the
> issue and for which i thought would illustrate the the issue clearly. it was
> not what i would use for anything with public consumption in mind. the code
> that is there right now looks like this:
>
> if([self didValueForInputKeyChange:@"inputMessages"]||self.inputResend)
>
> {
>
>     id myMessages=self.inputMessages;
>
> id myMsg;
>
> int numberOfMessages=[myMessages count];
>
> if([myMessages respondsToSelector:@selector(objectForKey:)])
>
> {
>
> for(int i=0;i<numberOfMessages;i++)
>
> {
>
>  if((myMsg=[myMessages objectForKey:[NSString stringWithFormat:@"%i"
> ,i]])==nil)
>
> myMsg=[myMessages objectForKey:[NSNumber numberWithInt:i]];
>
> if([myMessages respondsToSelector:@selector(valueForKey:)])
>
> {
>
> if([myMsg valueForKey:@"type"]!=nil&&[myMsg 
> valueForKey:@"channel"]!=nil&&[myMsg
> valueForKey:@"data1"]!=nil&&[myMsg valueForKey:@"data2"]!=nil)
>
> {
>
>  [midiManager sendMsg:[VVMIDIMessage createFromVals:
>
>   (Byte)[[myMsg valueForKey:@"type"] integerValue]&255:
>
>   (Byte)[[myMsg valueForKey:@"channel"] integerValue]&15:
>
>   (Byte)[[myMsg valueForKey:@"data1"] integerValue]&127:
>
>   (Byte)[[myMsg valueForKey:@"data2"] integerValue]&127]
>
>  ];
>
> // NSLog(@"%@",@"dict dict");
>
> continue;
>
> }else if([myMsg valueForKey:@"0"]!=nil&&[myMsg valueForKey:@"1"]!=nil&&[myMsg
> valueForKey:@"2"]!=nil&&[myMsg valueForKey:@"3"]!=nil)
>
> // this one happens when sending an array containing dictionaries, through
> a dictionary output port of a custom plugin, to a dictionary input of a
> custom plugin
>
> {
>
> [midiManager sendMsg:[VVMIDIMessage createFromVals:
>
>   (Byte)[[myMsg valueForKey:@"0"] integerValue]&255:
>
>   (Byte)[[myMsg valueForKey:@"1"] integerValue]&15:
>
>   (Byte)[[myMsg valueForKey:@"2"] integerValue]&127:
>
>   (Byte)[[myMsg valueForKey:@"3"] integerValue]&127]
>
>  ];
>
>  //NSLog(@"%@",@"dict idict");
>
>  continue;
>
> }
>
> else if([myMsg valueForKey:@"sysex"]!=nil)
>
>  }
>
> else if([myMsg respondsToSelector:@selector(objectAtIndex:)]&&[myMsg count
> ]>3)
>
> {
>
> [midiManager sendMsg:[VVMIDIMessage createFromVals:
>
>   (Byte)[[myMsg objectAtIndex:0] integerValue]&255:
>
>   (Byte)[[myMsg objectAtIndex:1] integerValue]&15:
>
>   (Byte)[[myMsg objectAtIndex:2] integerValue]&127:
>
>   (Byte)[[myMsg objectAtIndex:3] integerValue]&127]
>
>  ];
>
> //NSLog(@"%@",@"dict array");
>
> continue;
>
>  }
>
> NSLog(@"%@",@"Midi_Sender:The messagge data is not properly formated.");
>
> }
>
> }
>
> else if([myMessages respondsToSelector:@selector(objectAtIndex:)])
>
> {
>
> //this never really happens with a dictionary input but it may someday
>
> for(int i=0;i<numberOfMessages;i++)
>
> {
>
>  myMsg=[myMessages objectAtIndex:i];
>
> NSLog(@"%@",[myMsg description]);
>
> if([myMsg respondsToSelector:@selector(valueForKey:)])
>
> {
>
>   if([myMsg valueForKey:@"type"]!=nil&&[myMsg 
> valueForKey:@"channel"]!=nil&&[myMsg
> valueForKey:@"data1"]!=nil&&[myMsg valueForKey:@"data2"]!=nil)
>
> {
>
> [midiManager sendMsg:[VVMIDIMessage createFromVals:
>
>   (Byte)[[myMsg valueForKey:@"type"] integerValue]&255:
>
>   (Byte)[[myMsg valueForKey:@"channel"] integerValue]&15:
>
>   (Byte)[[myMsg valueForKey:@"data1"] integerValue]&127:
>
>   (Byte)[[myMsg valueForKey:@"data2"] integerValue]&127]
>
>  ];
>
> //NSLog(@"%@",@"array dict");
>
> continue;
>
> }else if([myMsg valueForKey:@"0"]!=nil&&[myMsg valueForKey:@"1"]!=nil&&[myMsg
> valueForKey:@"2"]!=nil&&[myMsg valueForKey:@"3"]!=nil)
>
>  {
>
> [midiManager sendMsg:[VVMIDIMessage createFromVals:
>
>   (Byte)[[myMsg valueForKey:@"0"] integerValue]&255:
>
>   (Byte)[[myMsg valueForKey:@"1"] integerValue]&15:
>
>   (Byte)[[myMsg valueForKey:@"2"] integerValue]&127:
>
>   (Byte)[[myMsg valueForKey:@"3"] integerValue]&127]
>
>  ];
>
> //NSLog(@"%@",@"array idict");
>
> continue;
>
> }
>
>  }
>
> else if([myMsg respondsToSelector:@selector(objectAtIndex:)]&&[myMsg count
> ]>3)
>
> {
>
> [midiManager sendMsg:[VVMIDIMessage createFromVals:
>
>   (Byte)[[myMsg objectAtIndex:0] integerValue]&255:
>
>   (Byte)[[myMsg objectAtIndex:1] integerValue]&15:
>
>   (Byte)[[myMsg objectAtIndex:2] integerValue]&127:
>
>   (Byte)[[myMsg objectAtIndex:3] integerValue]&127]
>
>  ];
>
> //NSLog(@"%@",@"array array");
>
> continue;
>
>  }
>
> NSLog(@"%@",@"Midi_Sender:The message dataaa is not properly formated.");
>
> }
>
> }
>
> else NSLog(@"%@", @"Midi_Sender:The data is not properly formated.");
>
> }
>
> return YES;
>
> this seems like a wrong way of doing it (so many if statements make me
> nervous). but at least it doesn't let complete nonsense get through. its
> kinda hard to decide how deep the checks should go.
> im trying to expose MIDI at a lower level than the other MIDI patches out
> there and im kinda hoping that the people who will try to assemble the
> structure by themselves will know what to do (fingers crossed:/).
> any suggestions about how to make it batter would be greatly appreciated. by
> me and everyone who ends up using the free plugin :).
>
>
>
>
>
>
>
> On Thu, Jul 1, 2010 at 10:16 PM, Christopher Wright <
> christopher_wri...@apple.com> wrote:
>
>> > im making a custom plugin that has a structure input port (array). when
>> i send it an array of dictionaries, the dictionaries become arrays. Why is
>> that?
>>
>> Just to entertain this idea some more, what happens if the user of said
>> plugin were to attach a structure of numbers to this input port?  That would
>> give you an array of NSNumbers (which also won't respond to -objectForKey:).
>>  Similar outcome happens for an array of strings, or colors, or pretty much
>> anything.
>>
>> The "array-ification" of the dictionaries is an unfortunate implementation
>> detail (being tracked by a radar, don't worry), but even if that's resolved
>> I think Tom's suggestion to check types first will likely be essential to
>> have reliable operation under general QC circumstances.  Thoughts on that
>> aspect?
>>
>> --
>> Christopher Wright
>> christopher_wri...@apple.com
>>
>>
>>
>>
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (Quartzcomposer-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to