首页 \ 问答 \ `[super viewDidLoad]`约定(`[super viewDidLoad]` convention)

`[super viewDidLoad]`约定(`[super viewDidLoad]` convention)

在实现之前和实现之后,我看到一些使用[super viewDidLoad]的示例代码。

我知道你不一定要打电话给超级(如许多其他讨论中所见)。 当你打电话时,是否在代码之前或之后预期?

这可能会影响到super的实现。 虽然你不应该知道super的实现来写你的。

当然,这适用于所有UIViewControllers委托方法(willAppear,didAppear等)

有什么想法吗?


I see some example code with [super viewDidLoad] called before your implementation and after your implementation.

I know you don't always have to call super (as seen in many other discussions). When you do call it, is it expected before or after you code?

This could have consequences depending on what super's implementation does. Though you shouldn't have to know super's implementation to write yours.

Of course this goes for all of UIViewControllers delegate methods (willAppear, didAppear, etc...)

Any thoughts?


原文:https://stackoverflow.com/questions/844195
更新时间:2023-08-16 18:08

最满意答案

#(车S)没有意义。 语法存在,但意味着符号CAR和S的向量。

使用

(funcall (first somelist) someargument)

要么

(apply (first somelist) a-list-of-arguments)

你的函数是非Lispy格式的。

后面的括号不会用在正确的Lisp代码中。 你也不需要引用数字。 数字是自我评估,他们评估自己。 此外,我们现在可能更倾向于CAR和REST over CDR。 功能相同,但名称更好。 每当我们处理简单的列表时,都会使用FIRST,SECOND,THIRD,...和REST。

(defun aritheval (S)
  (funcall (cond ((eq '+ (car S)) #'+)
                 ((eq '- (car S)) #'-)
                 ((eq '* (car S)) #'*)
                 ((eq '/ (car S)) #'/))
            2 3)))

由于符号可以用作全局函数的名称,因此以上不是必需的。

下面的这个函数也是一样的,因为从符号到函数的映射是相同的。

(defun aritheval (s)
  (funcall (first s) 2 3)))

#(car S) makes no sense. The syntax exists but means a vector with symbols CAR and S.

use

(funcall (first somelist) someargument)

or

(apply (first somelist) a-list-of-arguments)

Your function is non-Lispy formatted.

Trailing parentheses are not used in proper Lisp code. You also don't need to quote numbers. Numbers are self-evaluating, they evaluate to themselves. Also we now may prefer FIRST over CAR and REST over CDR. The functions do the same, but the names are better. Whenever we deal with simple lists, FIRST, SECOND, THIRD, ... and REST are used.

(defun aritheval (S)
  (funcall (cond ((eq '+ (car S)) #'+)
                 ((eq '- (car S)) #'-)
                 ((eq '* (car S)) #'*)
                 ((eq '/ (car S)) #'/))
            2 3)))

Since symbols can be used as names for global functions, above is not necessary.

This function below does the same, given the mapping from symbol to function is the same.

(defun aritheval (s)
  (funcall (first s) 2 3)))

相关问答

更多
  • 您的宏可以包含__FUNCTION__宏。 不要错,函数名将在编译时插入到扩展的代码中,但它将成为每次调用宏的正确函数名称。 所以它“看起来”是在运行时发生的;) 例如 #define THROW_IF(val) if (val) throw "error in " __FUNCTION__ int foo() { int a = 0; THROW_IF(a > 0); // will throw "error in foo()" } Your macro can contain the ...
  • 您可以使用libffi的闭包API 。 它允许您创建每个具有不同地址的蹦床。 我在这里实现了一个包装类,虽然还没有完成(只支持int参数和返回类型,你可以专门使用detail::type来支持更多只是int )。 更重要的替代方案是LLVM,但如果你只处理C类型,libffi将完成这项工作。 You can use the closure API of libffi. It allows you to create trampolines each with a different address. I i ...
  • 不,它不可能。 C ++不支持这种内省。 __PRETTY_FUNCTION__就是你要得到的。 No, it cannot be. C++ does not support this kind of introspection. __PRETTY_FUNCTION__ is all you're gonna get.
  • #(车S)没有意义。 语法存在,但意味着符号CAR和S的向量。 使用 (funcall (first somelist) someargument) 要么 (apply (first somelist) a-list-of-arguments) 你的函数是非Lispy格式的。 后面的括号不会用在正确的Lisp代码中。 你也不需要引用数字。 数字是自我评估,他们评估自己。 此外,我们现在可能更倾向于CAR和REST over CDR。 功能相同,但名称更好。 每当我们处理简单的列表时,都会使用FIRST, ...
  • 根据维基百科: 运行时库 / 运行时系统 。 在计算机编程中,运行时库是编译器使用的特殊程序库,用于在计算机程序的运行时(执行)期间实现内置到编程语言中的函数。 这通常包括用于输入和输出或用于存储器管理的功能。 运行时系统(也称为运行时系统或运行时)是软件,旨在支持以某种计算机语言编写的计算机程序的执行。 运行时系统包含基本的低级命令的实现,并且还可以实现更高级别的命令,并且可以支持类型检查,调试,甚至代码生成和优化。 运行时系统的某些服务可通过应用程序编程接口访问程序员,但其他服务(如任务调度和资源管理) ...
  • 我知道constexprt函数是在编译时处理的。 不准确的。 如果恒星需要对齐,可以使用constexpr函数。 这意味着它必须满足某些要求,但它仍然是一个功能。 而且你仍然可以使用它作为一个。 在你的情况下,该函数在运行时被编译和调用。 如果你要在需要常量表达式的地方使用它,并且在那里使用了带有throw的分支,那么你会看到一系列问题正在出现。 I know that constexprt functions are processed at compile time. Inaccurate. A con ...
  • 如果我正确理解你的问题。 你可以检查虚拟模块了。 或者,如果您希望能够重新加载required文件,则必须清除缓存并重新加载文件,这是该软件包可以执行的操作。 检查代码,你会明白。 模块在第一次加载后被缓存。 这意味着(除其他外)每次调用require('foo')将得到完全相同的对象返回,如果它将解析为相同的文件。 多次调用require('foo')可能不会导致模块代码被多次执行。 这是一个重要的功能。 通过它,可以返回“部分完成”的对象,从而允许传递依赖被加载,即使它们会导致循环。 更多信息可以在这里 ...
  • 您的测量代码中有相当多的潜在首次成本,这里有一对以及如何测试它们。 内存分配 :这些QVectors在第一次使用它们之前不会在堆上分配任何内存。 此外,向量很可能通过分配少量内存开始,然后在添加更多数据时以指数方式分配(对于像这样的容器的标准折衷)。 因此,在运行时开始时将有许多内存分配,然后频率会随着时间的推移而减少。 您可以通过查看QVector::capacity()的返回值来验证是否发生这种情况,并通过QVector::reserve(int)调整行为 - 例如,如果你执行timeMemory.re ...
  • 你需要使用反射。 假设您要调用的函数是名为Foo的类上的所有静态方法,您可以执行类似这样的操作。 Dim functionName as String = "listproducts" Dim fooType As System.Type = GetType(Foo) Dim Method As System.MethodInfo = fooType.GetMethod(functionName) Method.Invoke(Nothing, Nothing) You need to use reflec ...
  • 听起来你想创建一个SOURCEACCOUNT (或其他各种类),它引用了一个ACCOUNT ,并将封闭类的一些方法委托给ACCOUNT : class SOURCEACCOUNT{ ACCOUNT& account; public: explicit SOURCEACCOUNT(ACCOUNT& a):account(a){} void withdraw(int amount){ account.withdraw(amount); } // other methods which can e ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。