// A : Parent
@implementation A
-(id) init
{
// change self here then return it
}
@end A
A *a = [[A alloc] init];
Run Code Online (Sandbox Code Playgroud)
一个.只是想知道,如果自我是局部变量还是全局?如果是本地那么什么是点self = [super init]中init?我可以成功定义一些局部变量并使用这样的,为什么我需要将其分配给self.
-(id) init
{
id tmp = [super init];
if(tmp != nil) {
//do stuff
}
return tmp;
}
Run Code Online (Sandbox Code Playgroud)
湾 如果[super init]返回一些其他对象实例并且我必须覆盖self那么我将无法再访问A的方法,因为它将是全新的对象?我对吗?
C.super并self指向相同的内存,它们之间的主要区别是方法查找顺序.我对吗?
对不起,没有Mac试试,现在学习理论......
来自苹果的Objective C docs说
对于Objective-C的面向对象的构造,例如方法返回值,id将int替换为默认数据类型.(对于严格的C构造,例如函数返回值,int仍然是默认类型.)
我认为返回类型和因此值是方法签名中预定义的东西.那么你能举一些关于博士所指的例子吗?
我目前正在使用以下代码来呈现我的视图控制器.
CATransition* transition = [CATransition animation];
transition.duration = 1;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
[self.view.window.layer addAnimation:transition forKey:kCATransition];
[self presentViewController:viewController animated:NO completion:nil];
Run Code Online (Sandbox Code Playgroud)
我需要使用更复杂的动画利用UIView animateWithDuration方法.它只是模态演示和背景视图控制器应该留在那里.如何为呈现视图控制器的视图设置动画?
更新:下一版代码:)
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:NULL];
RootViewControllerEx *viewController = (RootViewControllerEx *)[sb instantiateViewControllerWithIdentifier:@"SB_RDVC"];
viewController.transitioningDelegate = self;
viewController.modalPresentationStyle = UIModalPresentationCustom;
[self presentViewController:viewController animated:YES completion:nil];
...
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
...
}
Run Code Online (Sandbox Code Playgroud)
故事板中的VC没有指定任何segue,它在故事板中保持孤独:)
我试图在模块内的测试中模拟单个函数。这是我只需要模拟的模块generateServerSeed
// seeds.js
const crypto = require('crypto');
const generateServerSeed = function () {
return crypto.randomBytes(4).toString('base64');
};
const hashServerSeed = function (serverSeed) {
const hash = crypto.createHash('sha512');
hash.update(serverSeed);
return hash.digest('hex');
};
module.exports = {
hashServerSeed,
generateServerSeed
};
Run Code Online (Sandbox Code Playgroud)
这是使用该模块的函数:
// blabla.js
import { generateServerSeed, hashServerSeed } from './seeds';
const VeryImportantFunction = () => {
const serverSeed = generateServerSeed();
const hash = hashServerSeed(serverSeed);
return hash;
};
module.exports = {
VeryImportantFunction
};
Run Code Online (Sandbox Code Playgroud)
这是我的测试文件
jest.mock('../seeds');
import { VeryImportantFunction } from '../blabla';
import { generateServerSeed …Run Code Online (Sandbox Code Playgroud) 在应用程序委托中创建的大多数情况下的托管对象上下文.将它传递给视图/控制器层次结构的方法有哪些,因此树中的每个导航/选项卡控制器都可以访问它.每次从父母到孩子的传递都可能不是最好的,因为我每次都必须携带这些信息,有时不是所有的控制器都可能需要它.
一旦iPhone应用程序进入 Ready for Sale状态,那么我想更改一些细节,如支持URL或关键字,它会改变状态,In Review我将不得不等待?
看来,为了调整图层的大小,必须从API角度选择它(从UI角度看)并激活它.否则,我在任何函数调用上都会收到错误,不支持此函数.
所以在调整大小之前我做了
var a = doc.artLayers.getByName("iPad");
app.activeDocument.activeLayer = a;
Run Code Online (Sandbox Code Playgroud)
这不会在视觉上改变所选层,因此调用resize函数失败.要让它工作的唯一方法,手动点击图层(任何图层),然后它就可以了.在没有用户交互的情况下调整图层大小的正确方法是什么?
在我的 Mac OS X 应用程序中,我删除了所有默认菜单项,添加了我自己的菜单项。
但是在View底部的菜单中我仍然可以看到Enter Full Screen菜单项,而在情节提要中没有这样的菜单项。
我试图删除整个View菜单,但现在它迁移到Window菜单。即使它被禁用,如果可能的话,我仍然想完全摆脱它。
这是 TwinCAT3 中的最少代码
// declaration
fTest : REAL := 32700.0;
// implementation
fTest := fTest + 0.001;
Run Code Online (Sandbox Code Playgroud)
该代码会将 fTest 增加到 32768。该数字不会再增加。任何高于 32768 的当前 fTest 值都将阻止其增加。数量保持不变。而且,即使我改为0.001,0.0019它0.0011仍然不会增加。然而,当我写0.002.
范围REAL从-3.402823e+38到产生3.402823e+38。但有一些与 32768 有关的东西。如何在 32768 以上的 fTest 中正确添加 0.001 或更低的值?这可能是 TwinCAT 中的一个错误吗?
更新:
有关 TwinCAT 中 REAL 的更多信息
根据 IEC 61131 3 / IEC 559 / IEEE754,32 位数据类型 REAL 的结构为 1 位符号、8 位以 2 为基数的指数(带符号)(-126...+127)、23 位尾数 (0 ...8,388,607)。