English 中文(简体)
没有工作的阵列,目标C
原标题:array shuffling not working, objective C

我有两种估计,一种是“预估”和一种“算术后”的,需要用我的直观块齐头。 我想随意执行。 我创造了众多数目,即0.33人。

NSNumber *w = [NSNumber numberWithUnsignedInt: 0];
NSNumber *x = [NSNumber numberWithUnsignedInt: 1];
NSNumber *y = [NSNumber numberWithUnsignedInt: 2];
NSNumber *z = [NSNumber numberWithUnsignedInt: 3];
NSArray *numbers = [[NSArray alloc] initWithObjects: w, x, y, z, nil];

I m using this category to arbitraryize the range.

 [numbers shuffledArray];

接着,我还有一套用心,从理论上来说,我用来拿走数字,用在我的空洞中:

int ww = [[numbers objectAtIndex:0] integerValue];
int xx = [[numbers objectAtIndex:1] integerValue];
int yy = [[numbers objectAtIndex:2] integerValue];
int zz = [[numbers objectAtIndex:3] integerValue];

[UIView animateWithDuration:.85 delay:3 options:opts animations:[animations objectAtIndex:ww] completion:[completions objectAtIndex:ww]];
[UIView animateWithDuration:.85 delay:8 options:opts animations:[animations objectAtIndex:xx] completion:[completions objectAtIndex:xx]];

等等。 我只字不提“同意:[编号标注AtIndex:0]是因为汇编者正在扔下“不相容的点子,把发往NSUInteger (aka unsign int )类参数的转换类型,”我这样做了,我试图通过将原子弹打成未经签名的内装,但在那里没有uck。

法典没有给我留下任何错误,而且一切都只是罚款,但没有任何东西被随意抽取,而是按我把一切放在首位的顺序排列。 关于我会错在哪里的想法? 我曾尝试过其他随机化职能,似乎没有任何工作。

最佳回答

From the code you posted, it appears you are not storing the returned NSArray anywhere. That is, shuffledArray does not shuffle the array in place, it returns a new shuffled array. Make sure you are storing it:

numbers = [numbers shuffledArray];

EDIT:如果你在<代码>上储存返回的阵列 除非你使用非洲排雷中心,否则确保你释放或将它自动释放。

问题回答

。 does 阵列:returns 你们没有抓住这一结果。 因此:

NSArray* result = [numbers shuffledArray];

现在的结果将uff。





相关问题
How do you create UIBarButtonItems with a radio interface?

I have a UIToolbar that needs three buttons in a radio style, meaning that of the three, only one button can be pushed at a time. The documentation makes reference to the possibility of setting up ...

iPhone settings bundle

I want to allow the user to enter a valid date using the iPhone’s settings application. I have experimented with many of the PreferenceSpecifiers data node types including date. I have two issues: ...

Circular #import/@class problem in ObjectiveC

I m going to use an example to properly illustrate my confusion. I can t quite wrap my head around this. In Cocoa touch, we have UIViewController and its subclass, UINavigationController. Now, UIVC ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Cocoa-Touch: issue looping MPMoviePlayerController

I have an app which has to load some data at startup, so I want to display a splash-screen animation. I m using the MPMoviePlayerController to play a m4v file. The movie has it s background set to [...

Iphone sequential animation with setAnimationDelay

I m trying to chain animation events. The application I m coding for work has a multiple choice quiz. First you pick your multiple choice answer. The quiz view fades away. Then a label ("correct" or "...

热门标签