小编Ric*_*ter的帖子

为什么DateTime.ToShortTimeString()不遵循"区域和语言设置"中的短时格式?

我遇到了一个问题,可能是由于我对DateTime.ToShortTimeString()方法如何工作的误解.使用此函数格式化时间字符串时,我假设它将遵循Windows 7格式设置中的"短时间"设置

Control Panel -> Clock, Language and Region -> Region and Language -> Formats Tab.

然而,.NET似乎选择了一种不基于此设置的短时间格式,而是基于当前的文化:

Region and Language -> Location -> Current Location

我在Windows 7 RC上做了一些测试:

Culture: en-GB, 6AM: 06:00, 6PM: 18:00 // HH:mm (United Kingdom)
Culture: en-GB, 6AM: 06:00, 6PM: 18:00 // hh:mm (United Kingdom)
Culture: en-US, 6AM: 6:00 AM, 6PM: 6:00 PM // HH:mm (United States)
Culture: en-US, 6AM: 6:00 AM, 6PM: 6:00 PM // hh:mm (United States)
Culture: el-GR, 6AM: 6:00 ??, 6PM: 6:00 ?? …

.net formatting time datetime cultureinfo

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

有没有办法以TypedStream格式读取文件

我有一个以下格式的文件:

NeXT/Apple typedstream data, little endian, version 4, system 1000
Run Code Online (Sandbox Code Playgroud)

在十六进制编辑器看着它,它明确提出了NS的一些对象(NSArray,NSValue,等).它似乎也有一个嵌入式plist!

我猜测有一种直接的方式来读取这个文件并以更可读的方式输出它(类似于repr()或的输出print_r()).

我假设我需要使用Objective-C做到这一点?

file objective-c next data-structures

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

如何让我的应用程序保持在全屏应用程序之上

我有一个必须始终保持在其他应用程序之上的应用程序.我目前正在使用主窗口的setLevel属性将其保持在其他桌面应用程序之上.

我正在尝试修复我的应用程序,因此它也可以保持在Lion的全屏应用程序之上.关于如何做到这一点的任何想法?

Application委托代码如下所示:

#import "alwaysOnTopAppDelegate.h"

@implementation alwaysOnTopAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    [window setLevel:NSFloatingWindowLevel];
}

@end
Run Code Online (Sandbox Code Playgroud)

xcode cocoa objective-c osx-lion

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

Applescript:如何使用默认程序打开文件?

在一个AppleScript中,我收到一个我要打开的文件路径.

文件路径的格式为" /Users/xxx/my/file/to/open.xyz".

我想用默认程序打开它.如果它是AVI,我需要用视频程序打开它,如果它是xls,有excel,......

我尝试了几件事但没有成功:

--dstfile contains the previous path
tell application "Finder"
    activate
    open document dstfile
end tell
Run Code Online (Sandbox Code Playgroud)

- >我收到错误1728,告诉我他无法获取文件

tell application "Finder"
    activate
    open document file dstfile
end tell
Run Code Online (Sandbox Code Playgroud)

- >在这里相同

tell application "Finder"
    activate
    open document POSIX file dstfile
end tell
Run Code Online (Sandbox Code Playgroud)

- >在这里相同

我确定该文件存在,因为我在此代码执行之前执行此操作:

if not (exists dstfile) then
    display dialog "File isn't existing"
end if
Run Code Online (Sandbox Code Playgroud)

我不能使用...的synthax open.xyz因为我收到它作为参数.

请帮助我绝望:'(

:基于答案,我最终得到了这个:

set command to "open " & quoted form of dsturl
do shell script command
Run Code Online (Sandbox Code Playgroud)

scripting applescript

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

UIAutomation:任何解除"想要使用当前位置"警报的方法吗?

我的应用程序正在使用位置服务,并且对于自动化测试,我希望能够忽略"APP想要使用您当前位置"弹出窗口.但是,当我尝试在带有UIAutomation脚本的Instruments中执行此操作时,我收到此错误:

Fail: Could not start script, target application is not frontmost.
Run Code Online (Sandbox Code Playgroud)

这种意义是有道理的,因为警报是由不同的过程产生的.但是,Apple在这种情况下帮助人们自动化测试的计划是什么?

instruments ui-automation ios ios-ui-automation

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

Mac OSX Lion/X11/CImg库

所以我试图将CImg图像写入库合并到我的XCode项目中但是,该库的头文件包含以下include和XCode给出此错误警告:

#include <X11/Xlib.h>  Error: File not found
Run Code Online (Sandbox Code Playgroud)

我的笔记本电脑正在运行OSX Lion 10.8.2,显然苹果为Lion取走了X11,所以我去了这个网站并下载了XQuartz,因为这就是它在Apple支持页面上所说的.

因此,在安装之后,我重新启动了我的计算机并尝试运行我的XCode项目,但我仍然得到相同的错误.

所以我不确定我现在应该做些什么来解决这个问题.如果我在Finder中搜索"XLib.h",它会出现,我有一个名为X11的文件夹,它也会出现在我的查找器中,所以我觉得我可能有我需要但我无法理解的东西.

x11 macos xcode osx-lion

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

如何在UI测试(Xcode)上关闭自动截图

我正在通过Jenkins运行Xcode的UI测试.每个步骤都会截取屏幕截图,因此在运行套件一段时间后,Mac会占用其所有硬盘空间.有谁知道你是否可以关闭Xcode UI Testing的自动截图,所以使用的空间更少?

iphone xcode screenshot xcode-ui-testing

10
推荐指数
3
解决办法
1937
查看次数

Apple的核心数据框架中的全文搜索

我想在iPhone应用程序中实现全文搜索.我有数据存储在我通过Core Data框架访问的sqlite数据库中.只是使用谓词和ORing每个搜索词和列的一堆"包含[cd]"短语根本不起作用.

你做了什么似乎运作良好?

sqlite iphone full-text-search core-data

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

在Open ES iPhone应用程序中围绕VBO使用VAO导致调用glDrawElements时出现EXC_BAD_ACCESS

我正在尝试将我的代码提升到一个新的水平.遵循Apple的一些最佳实践,我试图在我的顶点缓冲对象(VBO)周围实现顶点数组对象.我设置我的VBO和VAO像这样:

- (void)setupVBOs {  
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glBindVertexArrayOES(0);
    {
        glGenVertexArraysOES(1, &directArrayObject);
        glBindVertexArrayOES(directArrayObject);

    //    GLuint texCoordBuffer;
        glGenBuffers(1, &texCoordBuffer);
        glBindBuffer(GL_ARRAY_BUFFER, texCoordBuffer);
        glBufferData(GL_ARRAY_BUFFER, sizeof(DirectVertices), DirectVertices, GL_STATIC_DRAW);

        glVertexAttribPointer(directPositionSlot, 2, GL_FLOAT, GL_FALSE, sizeof(DirectVertex), (GLvoid*)offsetof(DirectVertex, position));
        glEnableVertexAttribArray(directPositionSlot);
        glVertexAttribPointer(texCoordSlot, 2, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(DirectVertex), (GLvoid*)offsetof(DirectVertex, texCoord));
        glEnableVertexAttribArray(texCoordSlot);

        glGenVertexArraysOES(1, &arrayObject);
        glBindVertexArrayOES(arrayObject);

    //    GLuint vertexBuffer;
        glGenBuffers(1, &vertexBuffer);
        glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
        glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);

        glVertexAttribPointer(positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
        glEnableVertexAttribArray(positionSlot);
        glVertexAttribPointer(colorSlot, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, Color));
        glEnableVertexAttribArray(colorSlot);

    //    GLuint indexBuffer;
        glGenBuffers(1, &indexBuffer);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW); …
Run Code Online (Sandbox Code Playgroud)

iphone opengl-es ios

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

AVAssetWriterInputPixelBufferAdaptor pixelBufferPool在一段时间后变为NULL

我在AVAssetWriterInputPixelBufferAdaptor中使用pixelBufferPool来创建像素缓冲区以与append方法一起使用.创建4个缓冲区后,pixelBufferPool属性变为NULL;

我设置了我的编写器,输入和适配器,如下所示:

- (BOOL) setupRecorder {
    NSError *error = nil;
    if([[NSFileManager defaultManager] fileExistsAtPath:[[self tempFileURL] path]])
        [[NSFileManager defaultManager] removeItemAtURL:[self tempFileURL] error:&error];


    assetWriter = [[AVAssetWriter alloc] initWithURL: [self tempFileURL] 
                                            fileType:AVFileTypeQuickTimeMovie
                                               error:&error]; 
    if (error) {
        NSLog(@"Error creating asset writer: %@", error);
        [assetWriter release];
        return NO;
    }
    // writer

    NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                   AVVideoCodecH264, AVVideoCodecKey, 
                                   [NSNumber numberWithInt:videoWidth], AVVideoWidthKey, 
                                   [NSNumber numberWithInt:videoHeight], AVVideoHeightKey,
                                   nil];

    assetWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo 
                                                      outputSettings:videoSettings];

    NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
                                      [NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey, 
                                      nil];

    adaptor = [[AVAssetWriterInputPixelBufferAdaptor alloc] initWithAssetWriterInput:assetWriterInput sourcePixelBufferAttributes:bufferAttributes];  
    [adaptor …
Run Code Online (Sandbox Code Playgroud)

iphone ios avassetwriter

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