小编0xD*_*15B的帖子

GameCenter邀请处理程序

试图实现多人游戏.使用Game Center中的示例- 发送和接收数据.

一切似乎都没问题,但在苹果文档中也有关于邀请处理程序的说法.

[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {
   // Insert application-specific code here to clean up any games in progress.
   if (acceptedInvite) {
        GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
        mmvc.matchmakerDelegate = self;
        [self presentModalViewController:mmvc animated:YES];
    } else if (playersToInvite) {
        GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
        request.minPlayers = 2;
        request.maxPlayers = 4;
        request.playersToInvite = playersToInvite;

        GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
        mmvc.matchmakerDelegate = self;
        [self presentModalViewController:mmvc animated:YES]; …
Run Code Online (Sandbox Code Playgroud)

multiplayer objective-c invite game-center

6
推荐指数
1
解决办法
4877
查看次数

游戏中心InviteFailed

我正在尝试发送游戏中心邀请.从模拟器发送到设备或从设备发送到模拟器会导致InviteFailed错误.

可能是什么问题?实施不正确?互联网速度低?或者是否无法使用模拟器测试Game Center邀请?

谢谢 邀请失败

iphone multiplayer objective-c game-center

5
推荐指数
2
解决办法
2868
查看次数

为什么Activity Monitor报告的内存使用量与分配工具之间存在差异

我面临着很奇怪的问题.

申请~80.Mb

使用Allocations Instrument在模拟器上进行测试,向我显示当前正在使用大约30 Mb,但是当使用Activity Monitor在iPod 4g上进行测试时显示"物理内存使用~133Mb"和"物理内存可用~77Mb"

由于内存警告我的应用程序不断崩溃.

ActivityMonitor和Allocations Instrument之间使用的物理内存有什么区别?

之前我已经信任Allocations Instrument,因为当我释放对象时,使用的内存量减少了,但在ActivityMonitor中,USED内存量以一种奇怪的方式增加和减少,这与我正在做的事情无关.所以,帮助我理解,因为我认为分配的内存与使用的内存相同,或者我错了?

编辑: 似乎我理解数据在activitymonitor中的显示方式.但问题仍然存在.在ActivityMonitor中,图表下方有一列.在那里我找到了我的申请.而且记忆力只会增加.

没有泄漏100%

memory allocation objective-c

4
推荐指数
1
解决办法
2003
查看次数

更改数组内的值

例如:我有一个可变数组的BOOL(或[NSNumber numberWithBool:TRUE];).然后我想改变,例如这个数组中的第一个值为FALSE.

[array addObject:[NSNumber numberWithBool:TRUE]];
[array objectAtIndex:0] ??? 
Run Code Online (Sandbox Code Playgroud)

我知道一种非常奇怪的方式来完成这项任务.

[array replaceObjectAtIndex:0 withObject:[NSNumber numberWithBool:FALSE]];
Run Code Online (Sandbox Code Playgroud)

是的,这完全满足了我,但我正在寻找另一种方式,这比这更简单.喜欢的东西[[array objectAtIndex:0] setBoolValue:FALSE];,例如,想象一下,如果我有UIButton的,而不是布尔值将:[[array objectAtIndex:0] setHidden:TRUE];或者这仅仅是梦想?

提前致谢!

boolean objective-c nsmutablearray

1
推荐指数
1
解决办法
9689
查看次数

奇怪的释放问题

我有一个奇怪的问题,但我很确定,因为你不是.如果是这样,请帮助我或解释.我有一个39 UIImages的数组,将用于动画UIImageView.播放动画后,内存不会释放.

- (void)viewDidLoad {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
    NSMutableArray* actionArray = [[NSMutableArray alloc]initWithCapacity:38];

    for (int i=1; i<=39; i++) {
        NSString* path = [[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"bg_Level1_%.4d", i] ofType:@"png"];
        UIImage *image = [[UIImage alloc]initWithContentsOfFile:path];
        [path release];
        [actionArray addObject:image];
        [image release];
        NSLog(@"path rc %d image %d", [path retainCount], [image retainCount]); 
    }
    imageView.animationImages = actionArray;
    imageView.animationDuration = 4.0;
    imageView.animationRepeatCount = 1;
    [imageView startAnimating];
    NSLog(@"RetainCount ActArr %d ImageView %d", [actionArray retainCount], [imageView retainCount]);
    [actionArray release];
    [pool drain];
    [imageView release];
    [self performSelector:@selector(playAnimation2) withObject:self afterDelay:5.0]; …
Run Code Online (Sandbox Code Playgroud)

iphone memory-management objective-c

-1
推荐指数
1
解决办法
171
查看次数