小编Chr*_*son的帖子

如何以编程方式确定正在运行的Mac OS X版本?

我有一个程序需要在Tiger上的行为略有不同于Leopard.有没有人知道系统调用,这将允许我准确地确定正在运行的Mac OS XI版本.我已经找到了许多宏定义来确定构建机器的操作系统,但是没有什么能够确定正在运行的机器的操作系统.

谢谢,乔

macos cocoa macos-carbon

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

如何使OS X上的"find"命令默认为当前目录?

我是一个沉重的命令行用户,并find在我的构建系统脚本中广泛使用该命令.但是在Mac OS X上,当我不专注时,我经常得到这样的输出:

$ find -name \*.plist
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
find: *.plist: No such file or directory
Run Code Online (Sandbox Code Playgroud)

基本上,我忘了添加小点:

$ find . -name \*.plist
Run Code Online (Sandbox Code Playgroud)

因为BSD find需要路径而GNU find不需要(如果你没有指定,则它假设当前目录).我经常同时使用Linux,Mac OS X和Cygwin,因此让我的所有工具表现相同对我有很大好处.我试着编写一个bash find函数,如果我忘了就添加"./",但是我失败了.谢谢你的帮助.:)

macos bash command-line find

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

使用NSCoder编码CGPoint结构

如何使用NSCoder编码和解码CGPoint结构?

cocoa

14
推荐指数
3
解决办法
5978
查看次数

在iPhone上切片UIImage

目标:取一个UIImage,在中间裁剪出一个正方形,将正方形的大小改为320x320像素,将图像切割成16个80x80图像,将16个图像保存在一个数组中.

这是我的代码:

CGImageRef originalImage, resizedImage, finalImage, tmp;
float imgWidth, imgHeight, diff;
UIImage *squareImage, *playImage;
NSMutableArray *tileImgArray;
int r, c;

originalImage = [image CGImage];

imgWidth = image.size.width;
imgHeight = image.size.height;
diff = fabs(imgWidth - imgHeight);

if(imgWidth > imgHeight){
    resizedImage = CGImageCreateWithImageInRect(originalImage, CGRectMake(floor(diff/2), 0, imgHeight, imgHeight));
}else{
    resizedImage = CGImageCreateWithImageInRect(originalImage, CGRectMake(0, floor(diff/2), imgWidth, imgWidth));
}
CGImageRelease(originalImage);

squareImage = [UIImage imageWithCGImage:resizedImage];      
if(squareImage.size.width != squareImage.size.height){
    NSLog(@"image cutout error!");
    //*code to return to main menu of app, irrelevant here
}else{
    float newDim = squareImage.size.width;
    if(newDim …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch image-manipulation objective-c

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

如何在UINavigationController标题视图中自定义后退按钮的文本颜色?

我在UINavigationController的导航栏上使用自定义tintColor,因为颜色太浅,我需要使用深色文本.交换标题视图和我在右侧添加的自定义按钮相对容易,但我似乎无法通过后退按钮获得自定义视图.这就是我现在正在尝试的:

    UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectZero];

    [backLabel setFont:[UIFont fontWithName:[[UIFont fontNamesForFamilyName:@"Arial Rounded MT Bold"] objectAtIndex:0] size:24.0]];
    [backLabel setTextColor:[UIColor blackColor]];
    [backLabel setShadowColor:[UIColor clearColor]];

    [backLabel setText:[aCategory displayName]];
    [backLabel sizeToFit];
    [backLabel setBackgroundColor:[UIColor clearColor]];

    UIBarButtonItem *temporaryBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:backLabel];

    temporaryBarButtonItem.customView = backLabel;
    [backLabel release];

    self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
    [temporaryBarButtonItem release];]
Run Code Online (Sandbox Code Playgroud)

虽然自定义视图不坚持,但我没有看到任何明显简单的方法来获取默认按钮内的实际文本并开始更改其样式.

iphone cocoa-touch

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

寻找有关界面组件的自定义绘图的信息(Cocoa)

现在看来越来越多的OS X应用程序正在为自定义控件做各种精美的绘图工作.像Twitterific,Things,EventBox,Versions等应用程序仅举几例....

所以基本上我正在寻找有关如何开始做这种事情的任何信息.不确定它是否只是通过子类化控件和使用自定义绘图来完成,或者它是否完全不同.

任何帮助是极大的赞赏.谢谢!

macos cocoa objective-c interface-builder

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

在via Cocoa的NSDate中解析不支持的日期格式

使用Cocoa框架,我如何将@"2008-12-29T00:27:42-08:00"解析为NSDate对象?标准-dateWithString:不喜欢它.

cocoa parsing date

13
推荐指数
3
解决办法
7807
查看次数

是否有Java等同于Apple的核心数据?

我最近听到了很多对Apple核心数据架构的赞誉.

在Java领域是否有类似的东西,以便我可以使用Core Data的想法(为了评估它如何与Hibernate之类的东西叠加)而不必首先进入Cocoa/Objective-C?

java persistence database-design core-data

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

Objective-C相当于C#中的"覆盖"

假设一个类Vehicle有一个名为"StartEngine"的方法,在我的子类中称为"Airplane",我想覆盖"StartEngine".如果我使用C#,我应该使用Airplane的StartEngine方法声明/定义中的"override"关键字.

我问的原因是,如果不是"StartEngine"我键入"startengine",C#会抱怨,但是由于该关键字,Objective-C不会.

objective-c

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

如何在Xcode中打开括号匹配?

卷曲支撑匹配很容易打开.如何在Xcode中打开括号匹配?

xcode text-editor

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