//
// Viewcontroller. m
// H
//
// Created by Jason on 13-3-1.
// Copyright (c) 2013 hufeng. All rights reserved.
//
# Import "viewcontroller. H"
@ Interface viewcontroller ()
@ End
@ Implementation viewcontroller
Typedef struct
{
Bool ishaskey;
Int position;
} Returndate;
-(Void) viewdidload
{
[Super viewdidload];
// Do any additional setup after loading the view, typically from a nib.
Nsdictionary * dict = @{
@ "Pushinfo ":@[
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info001 ",
@ "Modetype": @ "DB ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info002 ",
@ "Modetype": @ "St ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info003 ",
@ "Modetype": @ "ls ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info004 ",
@ "Modetype": @ "Ed ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info002 ",
@ "Modetype": @ "SD ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info005 ",
@ "Modetype": @ "SD ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info005 ",
@ "Modetype": @ "sddd ",
@ "Systemtype": @ "OA"
},
@{
@ "Content": @ "handling instructions ",
@ "Infoid": @ "info006 ",
@ "Modetype": @ "sddd ",
@ "Systemtype": @ "OA"
},
]
};
// Nslog (@ "The dict =%@", dict );
Nsarray * array = [dict objectforkey: @ "pushinfo"];
[Self returnkey: array key: @ "info002"];
Nsmutablearray * uniquarray = [nsmutablearray array];
Nsmutablearray * uniquarraytmp = [[array mutablecopy] autorelease];
For (INT I = [uniquarraytmp count]; I> 0; I --)
{
Nsstring * Key = [[uniquarraytmp objectatindex: I-1] objectforkey: @ "infoid"];
Returndate dt = [self returnkey: uniquarray key: Key];
If (Dt. ishaskey)
{
Nsmutabledictionary * dicta =
[[[Uniquarraytmp objectatindex: I-1] mutablecopy] autorelease];
Nsstring * A = [dicta objectforkey: @ "modetype"];
Nsmutabledictionary * dictb =
[[[Uniquarray objectatindex: DT. position] mutablecopy] autorelease];
Nsstring * B = [dictb objectforkey: @ "modetype"];
[Dicta setobject: [nsstring stringwithformat: @ "% @ ^ % @", a, B] forkey: @ "modetype"];
[Uniquarray replaceobjectatindex: DT. Position withobject: dicta];
}
Else
{
[Uniquarray addobject: [uniquarraytmp objectatindex: I-1];
[Uniquarraytmp removeobjectatindex: I-1];
}
}
Nslog (@ "The after \ n % @", uniquarray );
}
-(Returndate) returnkey :( nsarray *) array key :( ID) Key
{
Int I = 0;
Returndate date;
Date. Position = 0;
Date. ishaskey = no;
For (nsdictionary * dict in array)
{
If ([[dict objectforkey: @ "infoid"] isequal: Key]
)
{
Date. ishaskey = yes;
Date. Position = I;
Break;
}
Else
{
I ++;
}
}
Return date;
}
-(Void) didreceivememorywarning
{
[Super didreceivememorywarning];
// Dispose of any resources that can be recreated.
}
@ End