运行以下命令
virtualenv -p /usr/local/bin/pypy pypy
Run Code Online (Sandbox Code Playgroud)
退出时出错
Running virtualenv with interpreter /usr/local/bin/pypy
New pypy executable in pypy/bin/pypy
debug: WARNING: Library path not found, using compiled-in sys.path.
debug: WARNING: 'sys.prefix' will not be set.
debug: WARNING: Make sure the pypy binary is kept inside its tree of files.
debug: WARNING: It is ok to create a symlink to it from somewhere else.
'import site' failed
AttributeError: 'module' object has no attribute 'prefix'
ERROR: The executable pypy/bin/pypy is not functioning
ERROR: It thinks …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序获得访问在iOS 6的设置中注册的Facebook帐户后,我从我的facebook的隐私设置中撤消了该应用程序.然后我尝试通过调用[FBSession openActiveSessionWithReadPermissions ...]重新连接我的应用程序,并且该方法使用旧的访问令牌创建facebook会话,该令牌已经是INVALID,而不再请求权限授予.
我认为这个问题与这个问题有关(Facebook SDK 3.1 - 验证访问令牌的错误),据说它在SDK 3.1.1中得到修复.
但是,我正在使用SDK 3.1.1并通过在发生无效访问令牌错误时手动调用accountStore renewCredentialsForAccount事件来解决此问题.
在将viewController推入导航控制器之后,viewController的视图不会被加载.
这是我的代码片段.
- (void)myMethodInClassA {
// window's root view controller is navigation controller
UINavigationController *naviCtrl = (UINavigationController*)[UIApplication sharedApplication].keyWindow.rootViewController;
MyViewController *myVC = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[naviCtrl pushViewController:myVC animated:NO];
// at this point, myVC's view is NOT loaded
}
Run Code Online (Sandbox Code Playgroud)
当我打电话时myMethodInClassA
,myVC viewDidLoad
被称为AFTER,该方法返回.我希望在pushViewController:animated:
调用导航控制器之后和myMethodInClassA返回之前加载myVC的视图.
何时加载了视图控制器的视图?Apple的文档只是说它在首次访问时已加载.这有点模棱两可.为什么导航控制器的pushViewController:
访问视图控制器没有视图?
抱歉抱歉最初的模棱两可的问题.
我已尝试将相同的NSDictionary对象转换为NSData,然后使用NSJSONSerialization和SBJsonWriter多次转换为NSString,有时会得到不同的字符串.甚至是空的.这很奇怪,我找不到任何理由.=(JSONKit和YAJL没有这样的问题.以下是我的测试代码.
for (int i = 0; i < 5; i++) {
NSDictionary *d = [NSDictionary dictionaryWithObject:@"value" forKey:@"key"];
NSData *data = [NSJSONSerialization dataWithJSONObject:d options:0 error:nil];
NSLog(@"%@", [NSString stringWithUTF8String:data.bytes]);
}
Run Code Online (Sandbox Code Playgroud)
和控制台输出是......
2012-04-25 01:35:33.113 Test[19347:c07] {"key":"value"}
2012-04-25 01:35:33.114 Test[19347:c07] (null)
2012-04-25 01:35:33.114 Test[19347:c07] {"key":"value"}
2012-04-25 01:35:33.114 Test[19347:c07] {"key":"value"}
2012-04-25 01:35:33.115 Test[19347:c07] (null)
Run Code Online (Sandbox Code Playgroud)
每次运行测试代码时输出都会更改.数据的字节大小相同,但UTF8转换的字符串长度不同.
我已将NSNumber对象放入NSDictionary对象,然后弹出并将其分配给声明为NSString实例的变量.
NSString *test;
NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1000] forKey:@"key"];
test = [dict valueForKey:@"key"];
NSLog(@"%@, type of %@", test, NSStringFromClass([test class]));
return 0;
Run Code Online (Sandbox Code Playgroud)
运行上面的代码后,我发现声明为(NSString*)的测试类型是__NSCFNumber.为什么会发生这种情况以及为什么编译器没有给出警告或错误?我是否必须使用NSString构造函数,例如NSStringWithFormat ...,以便将测试保持为NSString的实例?
ios ×3
cocoa ×1
ios6 ×1
json ×1
nsobject ×1
objective-c ×1
pypy ×1
python ×1
sbjson ×1
viewdidload ×1
virtualenv ×1