说我有这个代码:
#import <UIKit/UIKit.h>
@interface MyView : UIView
@end
@implementation MyView
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// How can I get this to show up even when the button is touched?
NSLog(@"%@", [touches anyObject]);
}
@end
@interface TestViewAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
}
@end
@implementation TestViewAppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MyView *view = [[MyView alloc] initWithFrame:[window frame]];
[view setBackgroundColor:[UIColor whiteColor]];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Hiya!" forState:UIControlStateNormal];
[button setFrame:CGRectMake(100.0, 100.0, …Run Code Online (Sandbox Code Playgroud) 如何编译C-Python模块,使其在另一个模块中是本地的?例如,如果我有一个名为"bar"的模块和另一个名为"mymodule"的模块,如何编译"bar"以便通过"import mymodule.bar"导入?
(对不起,如果措辞不好,我不确定它的正确用语是什么.)
我在setup.py中尝试了以下操作,但它似乎不起作用:
from distutils.core import setup, Extension
setup(name='mymodule',
version='1.0',
author='Me',
ext_modules=[Extension('mymodule', ['mymodule-module.c']),
Extension('bar', ['bar-module.c'])])
Run Code Online (Sandbox Code Playgroud)
编辑
谢谢Alex.所以这就是我最终使用的:
from distutils.core import setup, Extension
PACKAGE_NAME = 'mymodule'
setup(name=PACKAGE_NAME,
version='1.0',
author='Me',
packages=[PACKAGE_NAME],
ext_package=PACKAGE_NAME
ext_modules=[Extension('foo', ['mymodule-foo-module.c']),
Extension('bar', ['mymodule-bar-module.c'])])
Run Code Online (Sandbox Code Playgroud)
当然还有一个名为"mymodule"的文件夹__init__.py.
这可能是一个简单的问题,但我似乎无法弄清楚如何做到这一点.基本上我想做的就是在关闭它之前淡出一个窗口:
[[window animator] setAlphaValue:0.0];
[window close];
Run Code Online (Sandbox Code Playgroud)
这样可以在没有[窗口关闭]的情况下正常工作,但是当包含它时,窗口似乎在动画结束之前关闭它(这显然不是我想要的); orderOut:,performClose:等似乎也发生了同样的事情.有什么方法可以避免这种情况吗?
我正在尝试在另一个编辑器(即 Vim)中模拟 Xcode 的 ?-R 击键;我以为我可以使用一些 shell 脚本和 applescript 来做到这一点,但它似乎无法正常工作:
open -a Xcode "MyProj.xcodeproj"
osascript -e 'tell app "Xcode"' -e 'build' -e 'launch' -e 'end tell'
Run Code Online (Sandbox Code Playgroud)
问题在于它会启动应用程序,而不管 Xcode 是否报告错误。有没有什么办法解决这一问题?
我在使用CGColorGetConstantColor()在iPhone上工作时遇到了一些麻烦.Apple的文档声称你可以传递任何"恒定颜色",而不会链接到恒定颜色实际上是什么,所以我假设你可以简单地使用OS X记录的那些:
CGColorRef blackColor = CGColorGetConstantColor(kCGColorBlack);
Run Code Online (Sandbox Code Playgroud)
但是,似乎并非如此,因为Xcode抛出了这个错误:"'kCGColorBlack'不可用(在/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks中声明) /CoreGraphics.framework/Headers/CGColor.h:123)"
任何人都知道新常数是什么(以及它们在哪里记录)?
我在网上搜索过,似乎无法找到文档甚至是PyAPI_DATA()的简单解释(即使它在Python头文件中使用并在python.org上引用).任何人都可以解释这是什么或指向我忽略的文档?
谢谢.
我有一个带有可选参数的指定初始化程序(类似于下面的代码),我想通过调用它来创建一个自动释放方法.有没有办法做到这一点?
@interface MyObject : NSObject
- (id)initWithArgs:(id)firstArg, ...;
+ (id)objectWithArgs:(id)firstArg, ...;
@end
@implementation MyObject
- (id)initWithArgs:(id)firstArg, ...
{
if (!firstArg || ![super init]) {
return nil
}
va_list argList;
va_start(argList, firstArg);
id currentObject = firstArg;
do {
NSLog(@"%@", currentObject);
} while ((currentObject = va_arg(argList, id)) != nil);
va_end(argList);
return self;
}
+ (id)objectWithArgs:(id)firstArg, ...
{
// return [[[MyObject alloc] initWithArgs:firstArg, ...] autorelease];
}
@end
Run Code Online (Sandbox Code Playgroud) objective-c ×4
c ×2
cocoa ×2
iphone ×2
python ×2
python-c-api ×2
api ×1
applescript ×1
cocoa-touch ×1
deprecated ×1
distutils ×1
xcode ×1