Objective-C for Java programmer Part 1 2

Source: Internet
Author: User
Objective-C for Java programmer Part 1
Object and basic type

Java contains the original, or a small part.InternalType. Are these values the objects one of the largest semantic differences between Java and smalltalk. In smalltalk, the original type is treated as an object and is transparent boxed through the compiler or virtual machine. In Java and objective-C, they are clear.

Java only has a small part of the original type. It has four types of signed integers, two types of floating point values, Boolean and character. All types of objective-C support the original type. Core Groups are similar, but there are some important differences. First, C defines only the minimum range of one type. In short Java, it is always 16 bits. The short value is usually 16 bits in C. JavaOneInt, always 32 bits.OneInt,
On a platform where C is 16,32 or 64bit, it may exist today, but it may be 128 bits in the future, but it is usually a 32-bit platform where you can use objective-C.

Inheritance in objective-CTypedefThere are many definitions from the C keyword and a standard. Stdint. h header, for example, defineUint32_tAndInt32_tType, always unsigned or signed on each platform, you can use a 32-bit integer.

OneTypedef"The objective-C standard provides type D which isBOOL, This should onlyYESOrNO. This is reallyOneChar (an octal group on most platforms), and there are various methods, it may get a value that is neitherYESOrNO.

The shares in Java and Objective-C are the same initialization rules of the original type. If they declare an object in an instance variable (what is a field called by Java), they will be initialized to the object that is instantiated when 0. If they are local variables, they will be initialized to an undefined value.

Technically, Objective-C does not define how to instantiate objects. Unlike Java, Objective-C does not define all the memory models. It inherits from the C object, by convention, allocated things, packaged CCalloc () functionLibrary function. On OS X, this package is quite complex, but the final result is that each object you create sets the uninitialized value to 0.

An important difference is that Objective-C inherits all the non-structural object types in C. Java, and everything is an object or a primitive. In Objective-C, you also have structures, original arrays, and unions.

Some structures used by Cocoa in some places, includingNSPoint, Which represents the point in a two-dimensional space. Different objects are always passed by reference, and the structure is usually passed by value. They are easier to create than real objects.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.