Objective c

Object C ramp up


atomic vs nonatomic

http://stackoverflow.com/questions/588866/whats-the-difference-between-the-atomic-and-nonatomic-attributes/36920240#36920240


copy, assign, retain

http://stackoverflow.com/questions/4510913/objective-c-assign-copy-retain

http://stackoverflow.com/questions/8927727/objective-c-arc-strong-vs-retain-and-weak-vs-assign


strong/weak  retain/unsafe_unretained

http://stackoverflow.com/questions/9784762/strong-weak-retain-unsafe-unretained-assign


Object C code compare written in C++

see Object C wikipedia


Object C apple doc address

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html


Object C  dot annotation vs brackets annotation

http://stackoverflow.com/questions/11474284/what-is-preferred-in-objective-c-dot-notation-or-square-bracket-notation

[My Summary: I usually use dot visit variable and brackets call method]


Object C object method call message mechanism

http://blog.csdn.net/likendsl/article/details/7566031

https://floriansblog.wordpress.com/2011/02/28/from-sel-to-imp-or-how-to-call-a-method/


When use category and when use subclass

http://stackoverflow.com/questions/8060884/when-to-use-categories-and-when-to-use-subclassing

http://rypress.com/tutorials/objective-c/categories

It’s important to note that a category can also be used to override existing methods in the base class, but you should never do this. The problem is that categories are a flat organizational structure. If you override an existing method in Car+Maintenance.m, and then decide you want to change its behavior again with another category, there is no way for Objective-C to know which implementation to use. Subclassing is almost always a better option in such a situation.


Property Vs Instances Variable

https://www.quora.com/Objective-C-programming-language-What-is-the-difference-between-an-instance-variable-and-a-property

http://stackoverflow.com/questions/4172810/what-is-the-difference-between-ivars-and-properties-in-objective-c

[My Summary: That’s could also explain why property has strong atomic tag, but variables doesn’t have]


Ivar == instance variable


Define public, private instance variable

http://stackoverflow.com/questions/17508777/need-to-declare-a-public-instance-variable-in-objective-c


Default instance variable is protected  

http://stackoverflow.com/questions/1262463/how-to-make-a-real-private-instance-variable


@class declare instead of import header file

http://stackoverflow.com/questions/4172810/what-is-the-difference-between-ivars-and-properties-in-objective-c


Interface define in .h or define in .m

http://stackoverflow.com/questions/3967187/difference-between-interface-definition-in-h-and-m-file

(Look the last comment: This answer is fairly old and the compiler has improved greatly since when it was initially written. The compiler no longer needs a declaration for a method if the method body is 'visible'. This means that class continuations (@interface className ()) will generally will now only contain private @propertys. )

Interface define in .m is actually called class extension.

http://rypress.com/tutorials/objective-c/categories

[My summary: In old objective C, the .m method need declare, so are put into class extension.  but nowadays, don’t need do declare.]


Define static or define constants

http://stackoverflow.com/questions/16330889/how-to-declare-static-variables-in-objective-c

!!!!!!There is no static variable for class in objective-c, but you can work around by

http://stackoverflow.com/questions/15979973/setting-static-variables-in-objective-c

[My Summary: all the static variable will available in whole project, different file’s static variable should have different name, else link error.

Object C should init all instances variables in init method !!!!!

So if you directly write instance variables into implementation outside of { }, its just a tricky that variable to the file, like we define static variables, but if you define same name in two different file will cause link error]


[My Summary:

define in header means if others know your name

define “private, protected, public” means if allow others access.

I think the ideal is that know == allow, if he know you, he is allowed to call you.

But in java, others know all your names, but some are not allow to access.

And In object c, others may know the variable in header but they are not allowed to access,(like just define a protected or private instance variable and has no get method) (as compare: if use property, it will auto generate get set method, it could say use property more meets make know == allow)

And In object c, variable is different with method,  method don’t have private, protected allow management, or we can say every method is public allowed to visit !!!!!!!     it only has know (in header) or not know (not in header).

But Object C can access method by SELECTOR, because it’s use message mechanism, so it can access the method only in .m if he could see .m source code to know the name of method.]


Copy vs mutableCopy

http://www.cnblogs.com/kenshincui/p/3885689.html

[My Summary: actually I think retain is shallow and copy/mutableCopy is deep,  mutableCopy could generate a mutable object


ARC

https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

[My Summary: ARC use @property to generate code to counting retain/autorelease and generate code to the dealloc instances variables.  Autorelease is a tech before ARC that will auto release for block variables, but you still need to write release in a class’s dealloc method.  Use ARC, no need to write retain, release, autorelease in your code. ARC running in compiler stage]


Memory Management

http://www.cnblogs.com/kenshincui/p/3870325.html

[My Summary:

the count +1 or release old object are all wrapper by ARC @property , because @property is just effect each properties get/set/exchange method

autorelease will auto release temporary variable objects when the block finish running,  so also no need to manually write the XXX.release method in block

ARC also handle one object instance variable release, no need to write instance variables release inside the dealloc method

??? How about the release status async tasks like NSUrlSession that won’t cancel the async task when current block finish

For summary, all the counting and release are hidden, coder no need to care about the memory]


Foundation framework

http://www.cnblogs.com/kenshincui/p/3885689.html


IOS learning map

http://blog.csdn.net/q199109106q/article/details/8596506


!!!!!  ATTENTION

Every array should alloc init, else although it will nil ,  but all method call during runtime though message mechanism, won’t prompt error if the method caller is nil

All the dictionary array, if use initWithOjbects method ,  key is at second, object at first

All the dictionary and array need to check the id’s type, (because dictionary are all object, if you assign a string pointer (real get from dictionary ) to a array pointer (you expect to get)  during runtime,  the assignment won’t prompt error, but where using it will prompt error

[nil method]   won’t prompt ay error because message mechanism

Don’t use The local variable async operation

Delegate should be the class variable, else it will be release and won’t be called, but completionBlock won’t have this issue because completionBlock has its life cycle won’t release the variable after outer block finish

Don’t name the toolbar function  “backButtonClicked” this will conflict with system method and won’t show error




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值