[OGo-Developer] stuffing an NSArray into a NSMutableDictionary
Marcus Müller
developer@opengroupware.org
Tue, 24 Apr 2007 10:23:21 +0200
--Apple-Mail-9--620177529
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
On 23.04.2007, at 20:42, Sebastian Reitenbach wrote:
> Hi Rafel,
>
>> NSMutableArray *temparray;
>> temparray = [[queuesdict objectForKey:[event
>> objectForKey:@"Queue"]
>> objectForKey:@"Agents"];
>>
> I had to change the
>
> temparray = [[queuesdict objectForKey:[[event
> objectForKey:@"Queue"]
> objectForKey:@"Agents"]];
>
> to let it compile, but then it ended up in an exception (Some
> NSConcrete8BitString does not recognize objectForKey) while running
> and I
That's obviously the wrong fix. I think the intended statement was:
temparray = [[queuesdict objectForKey:[event
objectForKey:@"Queue"]]
objectForKey:@"Agents"];
It's always a good idea to make code more readable by splitting
everything into little steps, i.e.:
--- snip ---
NSString *queueKey;
NSDictionary *queue;
NSArray *agents;
queueKey = [event objectForKey:@"Queue"];
queue = [queuesdict objectForKey:queueKey];
agents = [queue objectForKey:@"Agents"];
--- snap ---
Cheers,
Marcus
--
Marcus Mueller . . . crack-admin/coder ;-)
Mulle kybernetiK . http://www.mulle-kybernetik.com
Current projects: http://www.mulle-kybernetik.com/znek/
--Apple-Mail-9--620177529
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=ISO-8859-1
<HTML><BODY style=3D"word-wrap: break-word; -khtml-nbsp-mode: space; =
-khtml-line-break: after-white-space; "><BR><DIV><DIV>On 23.04.2007, at =
20:42, Sebastian Reitenbach wrote:</DIV><BR =
class=3D"Apple-interchange-newline"><BLOCKQUOTE type=3D"cite"><DIV =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; ">Hi Rafel,</DIV><DIV style=3D"margin-top: 0px; =
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: =
14px; "><BR></DIV> <BLOCKQUOTE type=3D"cite"></BLOCKQUOTE><BLOCKQUOTE =
type=3D"cite"><DIV style=3D"margin-top: 0px; margin-right: 0px; =
margin-bottom: 0px; margin-left: 0px; "><SPAN =
class=3D"Apple-converted-space">=A0 =A0=A0 =A0</SPAN>NSMutableArray =
*temparray;</DIV><DIV style=3D"margin-top: 0px; margin-right: 0px; =
margin-bottom: 0px; margin-left: 0px; "><SPAN =
class=3D"Apple-converted-space">=A0 =A0 =A0 </SPAN>temparray =3D =
[[queuesdict objectForKey:[event objectForKey:@"Queue"]<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></DIV><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN =
class=3D"Apple-converted-space">=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 </SPAN>objectForKey:@"Agents"];</DIV><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; =
min-height: 14px; "><BR></DIV> </BLOCKQUOTE><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I had to =
change the<SPAN class=3D"Apple-converted-space">=A0</SPAN></DIV><DIV =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN =
class=3D"Apple-converted-space">=A0 =A0 =A0 </SPAN>temparray =3D =
[[queuesdict objectForKey:[[event objectForKey:@"Queue"]<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></DIV><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN =
class=3D"Apple-converted-space">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 </SPAN>objectForKey:@"Agents"]];</DIV><DIV =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">to let =
it compile, but then it ended up in an exception (Some<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></DIV><DIV style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; =
">NSConcrete8BitString does not recognize objectForKey) while running =
and I<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></DIV></BLOCKQUOTE></DIV><DIV><B=
R class=3D"khtml-block-placeholder"></DIV>That's obviously the wrong =
fix. I think the intended statement was:<DIV><BR =
class=3D"khtml-block-placeholder"></DIV>=A0 =A0=A0 =A0temparray =3D =
[[queuesdict objectForKey:[event objectForKey:@"Queue"]]=A0<DIV =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; ">=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
objectForKey:@"Agents"];</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>It's always a good idea to =
make code more readable by splitting everything into little steps, =
i.e.:</DIV><DIV><BR class=3D"khtml-block-placeholder"></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><SPAN =
class=3D"Apple-style-span" style=3D"background-color: transparent;">--- =
snip ---</SPAN></FONT></DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><FONT =
class=3D"Apple-style-span" face=3D"Courier">NSString=A0 =A0 =
=A0*queueKey;</FONT></FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
color=3D"#000000"><FONT class=3D"Apple-style-span" =
face=3D"Courier">NSDictionary *queue;</FONT></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><FONT =
class=3D"Apple-style-span" face=3D"Courier">NSArray=A0 =A0=A0 =
=A0*agents;</FONT></FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
color=3D"#000000"><FONT class=3D"Apple-style-span" face=3D"Courier"><BR =
class=3D"khtml-block-placeholder"></FONT></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><FONT =
class=3D"Apple-style-span" face=3D"Courier">queueKey =3D=A0[event =
objectForKey:@"Queue"];</FONT></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><FONT =
class=3D"Apple-style-span" face=3D"Courier">queue =A0 =A0=3D [queuesdict =
objectForKey:queueKey];</FONT></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><FONT =
class=3D"Apple-style-span" face=3D"Courier">agents=A0 =A0=3D [queue =
objectForKey:@"Agents"];</FONT></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" color=3D"#000000"><SPAN =
class=3D"Apple-style-span" style=3D"background-color: transparent;">--- =
snap ---</SPAN></FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
color=3D"#000000"><SPAN class=3D"Apple-style-span" =
style=3D"background-color: transparent;"><BR></SPAN></FONT><DIV> <SPAN =
class=3D"Apple-style-span" style=3D"border-collapse: separate; =
border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant: normal; font-weight: =
normal; letter-spacing: normal; line-height: normal; text-align: auto; =
-khtml-text-decorations-in-effect: none; text-indent: 0px; =
-apple-text-size-adjust: auto; text-transform: none; orphans: 2; =
white-space: normal; widows: 2; word-spacing: 0px; "><SPAN =
class=3D"Apple-style-span" style=3D"border-collapse: separate; =
border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant: normal; font-weight: =
normal; letter-spacing: normal; line-height: normal; text-align: auto; =
-khtml-text-decorations-in-effect: none; text-indent: 0px; =
-apple-text-size-adjust: auto; text-transform: none; orphans: 2; =
white-space: normal; widows: 2; word-spacing: 0px; "><P style=3D"margin: =
0.0px 0.0px 0.0px 0.0px"><FONT style=3D"font: 12.0px Helvetica"><FONT =
class=3D"Apple-style-span" color=3D"#000000"><SPAN =
class=3D"Apple-style-span" style=3D"background-color: =
transparent;">Cheers,</SPAN></FONT></FONT></P><P style=3D"margin: 0.0px =
0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><FONT =
class=3D"Apple-style-span" color=3D"#000000"><SPAN =
class=3D"Apple-style-span" style=3D"background-color: =
transparent;"><BR></SPAN></FONT></P><P style=3D"margin: 0.0px 0.0px =
0.0px 0.0px"><FONT style=3D"font: 12.0px Helvetica"><SPAN =
class=3D"Apple-converted-space"><FONT class=3D"Apple-style-span" =
color=3D"#000000"><SPAN class=3D"Apple-style-span" =
style=3D"background-color: transparent;">=A0</SPAN></FONT><SPAN =
class=3D"Apple-converted-space"><FONT class=3D"Apple-style-span" =
color=3D"#000000"><SPAN class=3D"Apple-style-span" =
style=3D"background-color: =
transparent;">=A0</SPAN></FONT></SPAN></SPAN><FONT =
class=3D"Apple-style-span" color=3D"#000000"><SPAN =
class=3D"Apple-style-span" style=3D"background-color: =
transparent;">Marcus</SPAN></FONT></FONT></P><P style=3D"margin: 0.0px =
0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: =
14.0px"><BR></P><P style=3D"margin: 0.0px 0.0px 0.0px 0.0px"><FONT =
face=3D"Helvetica" size=3D"3" style=3D"font: 12.0px Helvetica">--<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></FONT></P><P style=3D"margin: =
0.0px 0.0px 0.0px 0.0px"><FONT face=3D"Helvetica" size=3D"3" =
style=3D"font: 12.0px Helvetica">Marcus Mueller<SPAN =
class=3D"Apple-converted-space">=A0<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></SPAN>.<SPAN =
class=3D"Apple-converted-space">=A0<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></SPAN>.<SPAN =
class=3D"Apple-converted-space">=A0<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></SPAN>.<SPAN =
class=3D"Apple-converted-space">=A0<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></SPAN>crack-admin/coder =
;-)</FONT></P><P style=3D"margin: 0.0px 0.0px 0.0px 0.0px"><FONT =
face=3D"Helvetica" size=3D"3" style=3D"font: 12.0px Helvetica">Mulle =
kybernetiK<SPAN class=3D"Apple-converted-space">=A0<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></SPAN>.<SPAN =
class=3D"Apple-converted-space">=A0<SPAN =
class=3D"Apple-converted-space">=A0</SPAN></SPAN><A =
href=3D"http://www.mulle-kybernetik.com">http://www.mulle-kybernetik.com</=
A></FONT></P><P style=3D"margin: 0.0px 0.0px 0.0px 0.0px"><FONT =
face=3D"Helvetica" size=3D"3" style=3D"font: 12.0px Helvetica">Current =
projects:=A0<A =
href=3D"http://www.mulle-kybernetik.com/znek/">http://www.mulle-kybernetik=
.com/znek/</A></FONT></P><BR =
class=3D"Apple-interchange-newline"></SPAN></SPAN> =
</DIV><BR></DIV></BODY></HTML>=
--Apple-Mail-9--620177529--