A strong walkthrough of the IOS object pointer and the underlying data type _ios

Source: Internet
Author: User

This article mainly introduces the object pointer and the basic data type in iOS how to make a strong turn, the following words do not say more directly to see the example detailed.

One, the object pointer's strong turn:

UIView *view = [UIView new];//new An object of UIView class Uilabel
= (*label *) Uilabel Strong to view;//pointer
Uilabel = @ "123 "//Assign value to label's Text property (call SetText method of label)

The above code will have a crash and crash message as follows:

-[uiview SetText:]: Unrecognized selector sent to instance 0x7ff1e14e03a0

Summary: The strong-turn object pointer does not change the memory stored in the object type, what is originally the object of the class, the strong turn will not change, but can easily invoke the strong to go to the class of methods and properties.

Two, C basic data type of strong transfer:

float weight = 60.12;
NSLog (@ "%d", (int) weight);

Printed information is: 60

The original value was changed by a strong change: 0.12 discarded

int height =;
NSLog (@ "%f", (float) height);

Printed information is: 70.000000

On the basis of the original value added. 000000 is a float type, perhaps only after a strong turn can be used%f correctly print the value of the height

Because

int height =;
NSLog (@ "%f", height);

Printed information is: 0.000000

The search for a strong transfer of the C basic data type is for reference only.

Summarize

The above is the entire content of this article, I hope the content of this article for your iOS developers can help, if you have questions you can message exchange.

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.