IPhone development error set

Source: Internet
Author: User

Start the iPhone practise project. There are many problems, which should be recorded first to avoid further attacks:

 

1. exc_bad_access:

Scenario 1: A pointer is converted twice and release is performed twice. In fact, only one release is required. Or avoid assigning values everywhere when using pointers.

Scenario 2: dynamically load another View Controller B in View Controller A, and uitableviewdelegate cannot be used in View Controller.

 

2. a batch of leaking warning errors occur in debug:

Scenario: nsthread is used. Call the following code:

[Nsthreaddetachnewthreadselector: @ selector (scheduletask) totarget: selfwithobject: Nil];

In-(void) scheduletask;, for example, adding pool management can prevent such errors:

-(Void) scheduletask {

// Create a pool

NSAID utoreleasepool * Pool = [[NSAID utoreleasepoolalloc] init];

//... Your code write here.

// Release the pool;

[Pool release];

}

 

3. In a non-main thread, do not create uiview or other activities, but place them in the main thread. You can update the display of uiview in a non-main thread.

 

4. Do not use the following method (leaks will be reported) when reading data to the array cyclically ):

While (sqlite3_step (statment) = sqlite_row ){

City * city = [[city alloc] init];


// Value

[Citys addobject: City];

[City release];
City = nil;
}

 

The following method should be used:

 City*City;

While (sqlite3_step (statment) = sqlite_row ){
City = [[city alloc] init];

// Value

[Citys addobject: City];

[City release];
City = nil;
}

 

5. After the xcode project is connected to SCM, the "125001 bogus FILENAME" error occurs during submission. What path contains '.', which has not been resolved yet.

 

6. Define an object in the data. A property of this object cannot be taken directly.

 

7. When you use the following code to jump to a view, you must shield the initwithnibname method from the Controller to be redirected. Otherwise, the view cannot be displayed.

Code

 

8. When SQLite is used, the following error occurs: undefined symbols: "_ sqlite3_free", referenced from:, similar to an error. After the query, I found that I forgot to reference the SQLite library file to the project.

9. About Timeout: When the request timeout is set in the following way, it does not work at all, and the timeout is still the default 240 s. When such a problem occurs, you can use nst to determine whether to time out and then handle it.

Nsmutableurlrequest * request = [[nsmutableurlrequestalloc] initwithurl: [nsurlurlwithstring: URI] cachepolicy: Authorization: 5.0f];

 

10. Code check:

If you're using xcode 3.2 and above in the build menu you can just select build & analyze, and it will give you the results in the build results.

 

11. In uitableview, when implementing this method, note-(uitableviewcell *) tableview :( uitableview *) tableview

Cellforrowatindexpath :( nsindexpath *) indexpath

If the cell contains a newly added control, you only need to add it for the first time and change the display value in the control each time you scroll.

Example: Code

 

12. When a custom view is used in the cell of tableview, if tableview has a new Delete action, the table row content will be messy.

 

13. When adding a sub-uiviewcontroller to uiviewcontroller, you do not need to release the sub-uiviewcontroller. When the sub-view is removed, dealloc is called for the first time. After that, dealloc is no longer called for each add or remove operation. It is estimated that it is the IOS cache.

 

14. When uitableview is of the group type, it takes a clever way to contract or expand a section, such as setting the section height and then reload the section. Beginedit and endedit are used on the Internet. However, the entire tableview is refreshed, and the user experience is poor.

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.