开发者

accessing specific bits of NSMutableArray components

开发者 https://www.devze.com 2023-02-06 08:08 出处:网络
a noob question here. i have a NSMutableArray defined as lanes = [[NSMutableArray arrayWithCapacity:3] retain];

a noob question here.

i have a NSMutableArray defined as

lanes = [[NSMutableArray arrayWithCapacity:3] retain];

the three components of the NSMutableArray are:

<Lane: 0x5544dc0; frame = (201 0; 66 460); alpha = 0.5; opaque = NO; autoresize = RM+BM; tag = 3; layer = <CALayer: 0x5544e30> >
<Lane: 0x55450c0; frame = (53 0; 66 460); alpha = 0.5; opaque = NO; autoresize = RM+BM; tag = 1; layer = <CALayer: 0x5545100>>
<Lane: 0x5546cb0; frame = (127 0; 66 460); alpha = 0.5; opaque = NO; autoresize = RM+BM; tag = 2; layer = <CALayer: 0x5546a10>>

how do I get only the 0x5544dc0, 0x55450c0 and 0x5546cb0 bits out of the array and assign them to three different variables for later use ?

开发者_如何学JAVA

thank you!


id object = [myArray objectAtIndex:i];


Lane *lane1 = [lanes objectAtIndex:0];
Lane *lane2 = [lanes objectAtIndex:1];
Lane *lane3 = [lanes objectAtIndex:2];

Don't get confused because of the verbose information you get when you print the content of the array.
Everything behind the address of your objects (0x5544dc0, ...) are just properties of the Lane object.

0

精彩评论

暂无评论...
验证码 换一张
取 消