我得到了一系列形状,如下所示.. 我的代码是......
responseElement = [[bodyElement childrenNamed:@"GET_AllProductFrameShapeResponse"] objectAtIndex:0];
resultElement = [[responseElement childrenNamed:@"GET_AllProductFrameShapeResult"] objectAtIndex:0];
for (SMXMLElement *eventElements in [resultElement childrenNamed:@"Get_FrameShape"])
{
NSMutableDictionary *dicEventsData = [[NSMutableDictionary alloc] init];
[dicEventsData setValue:[eventElements valueWithPath:@"FrameShape"] forKey:@"FrameShape "];
[frameShapeResult addObject:dicEventsData];
}
NSLog(@"frameShape result %@", frameShapeResult);
所以请获取具有形状目录
的以下数组frameShape result (
{
"FrameShape " = OVEL;
},
{
"FrameShape " = Wayfarer;
},
{
"FrameShape " = "Club Master";
},
{
"FrameShape " = Aviator;
},
{
"FrameShape " = Wayferer;
},
{
"FrameShape " = Rectangle;
},
{
"FrameShape " = Round;
},
{
"FrameShape " = Oval;
},
{
"FrameShape " = "Cat-Eye";
},
{
"FrameShape " = "Cat Eye";
},
{
"FrameShape " = ClubRound;
},
{
"FrameShape " = Square;
}
)
我想从给定的数组中跟随一个数组..不知道怎么做..
OVEL
徒步旅行者
俱乐部大师“
飞行员
Wayferer
矩形
圆
椭圆
猫眼
猫眼
ClubRound
方
感谢提前帮助..
答案 0 :(得分:0)
您可以按照以下方式修改代码,只获取形状数组..
responseElement = [[bodyElement childrenNamed:@"GET_AllProductFrameShapeResponse"] objectAtIndex:0];
resultElement = [[responseElement childrenNamed:@"GET_AllProductFrameShapeResult"] objectAtIndex:0];
for (SMXMLElement *eventElements in [resultElement childrenNamed:@"Get_FrameShape"])
{
[frameShapeResult addObject:[eventElements valueWithPath:@"FrameShape"]];
}
NSLog(@"frameShape result %@", frameShapeResult);
这将为您提供您想要的确切结果..
希望这有帮助:)
答案 1 :(得分:-1)
试试这个:
在键中添加空格
NSArray * FrameShape = frameShaperesult; // array of you result which contains dictionary objects.
FrameShape = [FrameShape valueForKey:@"FrameShape "]; // array that contains string objects which you mentioned in question
这个最终的FrameShape数组将仅包含字符串作为对象,您可以通过for循环访问每个。
如果你想要一个字符串中的所有对象试试这个:
NSString *str = [FrameShape componentsJoinedByString:@","]; // all object will join by ,(comma) you can change it as per your need.