English 中文(简体)
nanosleep()从来不“觉醒”到OS X狮。
原标题:nanosleep() never "wakes up" on OS X Lion

I m在狮子使用XCode 4.2。 当我对Debug的简介(Pressing Diamond+R)进行汇编时,当我叫南塞莱普时,我从未从这一功能中恢复过。 页: 1 如果我介绍该守则(建筑单元简介),那么它确实是回报。 I m 只是为XCode项目利用缺省情况。 在这里可以讨论什么想法?

为了照此办理,创立了一个品牌的新空白应用,并将以下代码贴上标识。 m:

#import "AppDelegate.h"
#import <time.h>

@implementation AppDelegate

@synthesize window = _window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSLog(@"Hello");
    struct timespec a;
    a.tv_nsec = 10000;

    /** THE FIX! **/
    a.tv_sec = 0;
    /** THE FIX! **/

    nanosleep(&a,NULL);
    NSLog(@"World");
}

@end

<>Expected conduct: 在Hello之后,“世界”印刷成0.01 ms。

Actual conduct: 只有“Hello”印刷,没有窗户。

最佳回答

具体指明<代码>a.tv_sec至0。 也许,它先入住一些垃圾,使睡觉长几秒。


或者,请rel=“noreferer”>。

#include <unistd.h>

...

NSLog(@"Hello");
usleep(10);      // 0.010 ms = 10 µs = 10000 ns
NSLog(@"World");
问题回答

你们的结构分配在分数上,因此,你可能拥有精干/直率的数据。

缩略语 页: 1

struct timespec a;

a.tv_sec  = 0;
a.tv_nsec = 10000;

nanosleep( &a, NULL );




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签