初始化器在其他面向对象的语言中(比如Java)指的是构造器.

Objective-C同样拥有对象构造器在init形式的方法中.不管如何,在Objc中这些方法没有什么特殊的行为.

按照惯例,程序猿在init方法中设置对象初始的状态,但是实际上它们和其他的Objc方法一样.

因为它们像任何其他的Objc方法,程序猿必须从init方法显示返回已初始化的对象.特别的,这些方法只是简单的返回它们的接收者(receiver)(常常在最后一行中以return self结尾),但是它也有可能返回一个完全不同的对象(这通常被称为”类族 class clusters”,比如说NSString)

Swift的初始化器的行为更像是Java中的构造器,你使用它们唯一的目的是设置一个类或结构的新实例,并且你不需要从Swift的初始化器中返回任何对象或其他值.

Objective-C's Init Method的更多相关文章

  1. SSH项目练习的时候报错:[applicationContext.xml]: Invocation of init method failed;

    这里是控制台的报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...

  2. The init method

    The init method is a special method that gets invoked when an object is instantiated. Its full name ...

  3. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  4. Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...

  5. java代码中init method和destroy method的三种使用方式

    在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...

  6. MyBatis笔记----报错:Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/ij34/mybatis/applicationContext.xml]: Invocation of init method failed; nested exception is org.sp

    四月 05, 2017 4:51:02 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRef ...

  7. org.springframework.beans.factory.BeanCreationException,Invocation of init method failed,Context initialization failed

    G:\javaanzhuang\apache-tomcat-\bin\catalina.bat run [-- ::,] Artifact ssm_qingmu02_web:war exploded: ...

  8. Invocation of init method failed; nested exception is java.text.ParseException: '?' can only be specfied for Day-of-Month or Day-of-Week.

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronTrigger' ...

  9. spring init method destroy method

    在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...

  10. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...

随机推荐

  1. Linux下文件权限(一)用户ID和用户组ID

    最近在读<unix环境高级编程>,看到文件权限这里比较糊涂,主要设计多个用户ID和用户组ID,包括下面两个: (1)实际用户ID和实际用户组ID:这一部分表示我们究竟是谁.这两个字段在登录 ...

  2. lsdyna进阶教程-弹性球撞击刚性平板

    在lsdyna基础教程中,我们做了一个关于刚性球撞击弹性平板的粒子,现在我们考虑另外一个问题,如果用弹性球撞击刚性地面该怎么做呢?是不是要从头开始建模,操作步骤是不是一样呢?其实很简单,将球和地面的材 ...

  3. winform中的数据绑定

    1. 简单的数据绑定 例1 using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[& ...

  4. [USACO 08JAN]Telephone Lines

    Description Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone compa ...

  5. [PA 2014]Pakowanie

    Description 你有n个物品和m个包.物品有重量,且不可被分割:包也有各自的容量.要把所有物品装入包中,至少需要几个包? Input 第一行两个整数n,m(1<=n<=24,1&l ...

  6. codeforces round #419 C. Karen and Game

    C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...

  7. poj 3384 半平面交

    Feng Shui Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5183   Accepted: 1548   Speci ...

  8. Mysql安装的详细教程

    首先,针对本人最近几天各种电脑安装数据库失败,反思总结所有的方式.现写出详细教程,希望别的人少走弯路. 首先 这次内容分为如下几步 : 1.mysql之前安装的彻底清除 2.mysql版本的选取 3. ...

  9. python (3.5)字符串 持续更新中………………

    # 字符串与变量连接输出 name = input("请输入姓名")age = input("请输入年龄")job = input("请输入工作&qu ...

  10. TensorFlow 聊天机器人开源项目评测第一期:DeepQA

    聊天机器人开源项目评测第一期:DeepQA https://github.com/Conchylicultor/DeepQA 用 i5 的笔记本早上运行到下午,跑了 3 轮的结果,最后效果并不理想.官 ...