Some of the iOS Development Kit Kat 3

Source: Internet
Author: User

What is the difference between cgfloat and float?

Now that the apps on the shelves require support for 64-bit systems, the difference between cgfloat and float is here. command+ Left click CGFloat.

1 typedef CGFLOAT_TYPE CGFloat;

Here you can see that cgfloat is a macro definition of cgfloat_type, so what is this?

1234567891011 #if  defined (__lp64__)  && __lp64__ # define cgfloat_type double # define  cgfloat_is_double 1 # define cgfloat_min dbl_min # define cgfloat_max dbl_max #else # define cgfloat_type float # define cgfloat_is_double 0 # define cgfloat_min flt_min # define cgfloat_max flt_max #endif

The meaning of this passage is that, under 64-bit systems, cgfloat is a double type and a float type under a 32-bit system. CGFloat can ensure that your code is not error-prone under 64-bit systems, so your code should use CGFloat as much as possible. Although he may have caused some unnecessary consumption. But it's safe.

Should constants be defined using Foundation_export or # define?

General iOS There are two ways to define constants, see the following example

My. h file

12 FOUNDATION_EXPORT NSString * const kMyConstantString;  FOUNDATION_EXPORT NSString * const kMyConstantString2;

The. m file is defined like this

12 NSString * const kMyConstantString = @"Hello";NSString * const kMyConstantString2 = @"World";

There is also a commonly used # define method.

1 #define kMyConstantString @"Hello"

What difference does it have?

Use the first method to detect whether the value of a string is equal or faster. For the first you can use it directly (stringinstance = = myfirstconstant), and define uses this. ([Stringinstance isequaltostring:myfirstconstant])

Which efficiency is high, it is obvious. The first is to directly compare the pointer address, and the second is to compare each character of the string in equal form.

What does the static inline function do?

If your. m file requires frequent calls to a function, it can be declared with static inline, which is equivalent to defining the function body as a large macro. But this is not completely effective, can not be completely valid, the function of the body to a large macro definition to see the compiler mood, if it feels that your method is too complex, He won't turn around. He calls the function directly.

Like this simple function, he must be happy.

1 static inline CGRect ScaleRect(CGRect rect, float n)

What the hell is this? static void *capturingstillimagecontext = &CapturingStillImageContext;

This declarative approach is commonly used in KVO, which is used as a CONTENXT key to add.

1 [self addObserver:self forKeyPath:@"stillImageOutput.capturingStillImage"options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:CapturingStillImageContext];

This declarative approach can result in a method to create a unique pointer at compile time. Create a unique pointer when compiling. Because when the context of KVO is accidentally repeated, Something strange will happen. In this way can be avoided.

How to quickly locate the crash position?

Select Add Exception Breakpoint

This way, if your app is crash, it will automatically navigate to that sentence.

Fastest way to improve smoothness?

Use instrument to find all view,layer that do not need to be transparent but transparent. all made opaque.

Select Profile


Select the color blended Layers

Choose our recently-Weibo client

And then you'll see these things.

Red or crimson is transparent layers and view, they are the culprit to slow down your FPS, if you do not need to be transparent to get rid of.

A magical tool, Accessorizer.

In the end of the mouth, look at the picture will know.

The software I installed

Some of the iOS Development Kit Kat 3

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.