小编Jos*_*ell的帖子

尽管故意过度释放,但物体的保留计数从未低于1

我正在检查一些对象的保留计数

NSLog(@"r = %d", [aObject retainCount];
Run Code Online (Sandbox Code Playgroud)

似乎我能得到的最低值是"r = 1",即使我故意添加额外的"释放"调用

[aObject release];
Run Code Online (Sandbox Code Playgroud)

即使我尝试将"释放"和"NSLog"测试代码放在对象的dealloc 方法中,"r = 1"限制仍然 有效.

Cocoa运行时似乎忽略了我的额外版本,直到"r = 1",然后在示例程序的最后使用"EXC_BAD_ACCESS"崩溃(没有GC).

我唯一的解释(猜测)是我们需要r> = 1来访问对象.并且Cocoa运行时只是试图避免让任何对象的保留计数过早地变为0.

如果我错了,有人可以确认或纠正我吗?

cocoa memory-management objective-c retaincount

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

使用ggplot在y轴上绘制多个变量

我是R的初学者,我遇到了问题,需要你的帮助.

我有一个包含这样的数据的文本文件:

   A             C             G    class     phylum       order
-0.000187   -0.219166   1.693306 Chordata   Monotremata   Mammalia  
0.015664    -0.264506   1.482692 Chordata   Batidoidimorpha   Chondrichthyes    
-0.404323   0.219374    2.230190 Platyhelminthes   Cyclophyllidea   Cestoda 
Run Code Online (Sandbox Code Playgroud)

但当然它有很多行.我想以这样的方式绘制这些数据,即所有类都绘制在x轴上,每一个都将A,C和G值绘制为geom_point,并且这些点使用具有特定线的线连接颜色取决于A,C或G.我设法通过使用plot和par函数来实现这一点,但现在我想使用ggplot库来完成它.

提前致谢.

r ggplot2

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

以编程方式更改桌面映像

我正在尝试更改桌面图像; 我提出的程序如下.第一次运行此代码时,调整大小的图像在屏幕上显示为壁纸,但下次没有反应.我究竟做错了什么?

-(IBAction)click:(id)sender
{
    NSData *sourceData;
    NSError *error;
    NSFileManager *filemgr;
    filemgr = [NSFileManager defaultManager];
    screenArray = [NSScreen screens];
    screenCount = [screenArray count];
    unsigned index  = 0;

    for (index; index < screenCount; index++)
    {
        screenz = [screenArray objectAtIndex: index];
        screenRect = [screenz visibleFrame];

    }
    NSLog(@"%fx%f",screenRect.size.width, screenRect.size.height);

    arrCatDetails = [strCatDetails  componentsSeparatedByString:appDelegate.strColDelimiter];

    NSString *imageURL = [NSString stringWithFormat:@"upload/product/image/%@_%@_%d.jpg",[arrCatDetails objectAtIndex:0],appDelegate.str104by157Name,iSelectedImgIndex];
    NSString *ima = [imageURL lastPathComponent];
    NSString *str = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *dataFilePath = [str stringByAppendingPathComponent:ima];
    NSString *imagePath = [NSString stringWithFormat:@"file://localhost%@",dataFilePath];
    NSURL *url = [[NSURL alloc] …
Run Code Online (Sandbox Code Playgroud)

macos desktop cocoa objective-c

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

在python中动词的NodeBox错误

我下载了包http://nodebox.net/code/index.php/Linguistics#verb_conjugation 即使我试图获得动词的时态,我也会收到错误.

import en
print en.is_verb('use')
#prints TRUE

print en.verb.tense('use')

KeyError                                  Traceback (most recent call last)

/home/cse/version2_tense.py in <module>()
----> 1 
      2 
      3 
      4 
      5 

/home/cse/en/__init__.pyc in tense(self, word)
    124 
    125     def tense(self, word):
--> 126         return verb_lib.verb_tense(word)
    127 
    128     def is_tense(self, word, tense, negated=False):

/home/cse/en/verb/__init__.pyc in verb_tense(v)
    175 
    176     infinitive = verb_infinitive(v)
--> 177     a = verb_tenses[infinitive]
    178     for tense in verb_tenses_keys:
    179         if a[verb_tenses_keys[tense]] == v:

KeyError: ''
Run Code Online (Sandbox Code Playgroud)

python nodebox

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

如何创建透明通知窗口?

我不确定正确的名称,但我想知道如何创建(在Objective-C中)透明通知"窗口/面板",例如当您更改音量强度,键盘照明或显示亮度时显示.我想在其上放置我自己的图标/文字,以供我自己通知.我不知道谷歌的话,所以我在这里问.谢谢你的任何建议.

cocoa objective-c

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

是否有可能找到iPhone的刷新率?

我想知道是否可以通过编程方式找到iPhone屏幕的刷新率.我搜索过,但没有找到私有API.

有没有办法找到这个?

提前致谢.

iphone screen objective-c ios

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

如何从UITableView取消选择对象?

我想知道如何从我的身上取消一个物体UITableView.其中一个单元格被突出显示或选中,我想取消选择它,以便不选择任何UITableView单元格.我怎么能这样做?

cocoa-touch uitableview ios

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

如何在视图消失时暂停和重新启动NSTimer?

我NSTimer在我的视图类中使用一个每15秒调用一次.我的问题是,它工作正常,但我的应用程序变慢,因为它显示了整个应用程序的性能.所以我想暂停NSTimer当我的视图从超级视图中消失并在出现时重新启动计时器.请帮我解决问题.这是我的代码:

- (void) viewWillAppear:(BOOL)animated
{

    if(!Thread_bool)
    {
        //[spinner startAnimating];
        NSTimer *timer_new1=[[NSTimer alloc] init];
        timer_new1=[NSTimer scheduledTimerWithTimeInterval:2.0 target:self                selector:@selector(threadMethod) userInfo:nil repeats:YES];
        self.timer_new=timer_new1;
        [timer_new1 release];
        [self.tableView setEditing:NO];
        isEditing=NO;
        Thread_bool=YES;    
    }
}

-(void)viewWillDisappear:(BOOL)animated
{
    [self.timer_new invalidate];
    timer_new=nil;  
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c nstimer ios

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

将毫秒转换为分钟

如何在Objective-C或C中将毫秒转换为分钟或小时?

c math time objective-c

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

尝试使用MPMoviePlayerController播放视频,只获取音频

我想在我的iPhone应用程序中播放视频.我用过这段代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *movieUrl = [NSURL fileURLWithPath:
                       [[NSBundle mainBundle] pathForResource:@"Myvideo" 
                                                       ofType:@"mp4"]];

    //create a new instance of MPMoviePlayerController
    MPMoviePlayerController* myMovie=[[MPMoviePlayerController alloc] 
                                      initWithContentURL:movieUrl];

    //disable scaling of our movie
    myMovie.scalingMode = MPMovieScalingModeNone;

    //don't show any controls
   // myMovie.movieControlMode = MPMovieControlModeHidden;

    //you can specify at which time the movie should 
    //start playing (default is 0.0)
    myMovie.initialPlaybackTime = 2.0;

    //register a callback method which will be called
    //after the movie finished
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieFinished:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:myMovie]; 

    //start the movie (asynchronous …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c mpmovieplayercontroller ios

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