What is the definition of Convenience Method in regards to Objective C?

后端 未结 2 1384
猫巷女王i
猫巷女王i 2021-02-15 15:56

In most languages I have dealt with, one something is called a convenience method, it means that the method does some small task that gets done very frequently, and therefore it

2条回答
  •  故里飘歌
    2021-02-15 16:19

    So far as I know, "convenience method" means basically what you defined it to mean here: a single method or function which replaces a more complicated series of invocations because of its frequency of use.

    In Objective-C, the "ordinary" way to create a new instance is something along the lines of NSSomething * mySomething = [[[NSSomething alloc] initWithParam:... andParam:...] autorelease]. Many classes provide convenience constructors which simplify these three steps (in fact, in most cases, they probably literally do exactly the same thing, but wrapped behind a class method call).

提交回复
热议问题