One, non-arc memory management issues.
Some students forget about the arc when they created the project, causing some member properties to be released inexplicably. Then there was a series of inexplicable errors.
A wild pointer error occurred while scrolling the UITableView.
When these wild pointer errors occur, the first thing to think about is that some objects are released, and then there is nothing in the code that causes the object to be released, and it should be immediately thought that it is probably non-arc. How to see if the project is non-arc.
There is no concept of strong references in non-arc, so member variables are not strongly referenced.
In a look, the Allpro array is not called through Alloc, and the objects produced without the call Alloc are automatically freed.
1allpro=@[2 @{3kcities:@[@"Pudong",@"Yangpu",@"Zhabei",@"Minhang"],4Kheader:@"Shanghai",5Kfooter:@"Shanghai is good"6 },7 @{8kcities:@[@"Haidian",@"changping",@"Tiananmen Square"],9Kheader:@"Beijing",TenKfooter:@"Beijing is very good" One } A -];
So there is a wild pointer error when scrolling, so you need to change the project to arc. Such as
Two tick all must be selected, and then always point to confirm the OK.
Second, the data Model attributes adopted in the strategy in addition to the basic types need to use assign, strings need to use copy, other object types need to use strong. The strategy used by the view in the controller needs to depend on the situation.
Is that the property in the data model is using the wrong policy, causing the data to be lost when the UITableViewCell is re-presented to the interface.
Third, want to do something when clicking on the cell, the method is wrong.
The following two methods are too similar, so it is easy to choose the wrong one.
1 // This method is called when a row of cells is clicked 2 -(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath 3// when a row of cells is deselected, this method is called 4 -(void) TableView: (UITableView *) TableView Diddeselectrowatindexpath: (Nsindexpath *) Indexpath
Four, small string debugging skills
When a string is converted to a basic data type, the string is printed with a value, but converted to a basic data type of 0 o'clock, this puzzling problem, first of all, it should be thought that the string is likely to have a newline match, resulting in the conversion is unsuccessful.
@" 123"; = [str integervalue]; NSLog (@ "%@", str); NSLog (@ "%d", I); In this case, you can add a number to each side of the placeholder when you print the string. NSLog (@ "1%@1", str);
And then look at the printout to see how many blank lines there are in the string.
As long as the empty line is removed, it can be converted successfully. Ways to remove whitespace from a string:
// This method is a string that is clipped by what character set. -(NSString *) Stringbytrimmingcharactersinset: (Nscharacterset *)set;
The Nscharacterset object can be created by using the class method
// creating spaces and newline character sets [Nscharacterset Whitespaceandnewlinecharacterset]; // Create a space character set [Nscharacterset Whitespacecharacterset];
The warning means: when initializing, the type points to a mismatch and should be used Nsarray * instead of Yzperson *
After you find the reason, then look at how the person method is declared.
WORKAROUND: Change Nsarray * to ID.
Vi. UITableView Data Source issues
1.1
Error reason: Said Yzviewcontroller did not implement Tableview:numberofrowsinsection:
Solution: Implement Tableview:numberofrowsinsection:
1.2
Return empty here, will error.
UITableView Internal Implementation principle:
The data source implements this method
1 -(uitableviewcell*) TableView: (uitableview*) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath23//TableView internal automatically calls the following method to add the cell. 4[TableView Addsubview:cell]; 5 6 // If the returned cell is empty, it also means that the following line of code is generated. 7 [TableView Addsubview:nil];
The Addsubview is added to the array to save the right argument, and the array cannot add null values. None of the collection objects can be passed empty. For example, arrays, dictionaries, nsset.
Summary of the above error: the data source as TableView must implement two methods.
Number of rows returned
-(Nsinteger) TableView: (uitableview*) TableView numberofrowsinsection: (nsinteger) Section;
Returns the content displayed for each row
-(uitableviewcell*) TableView: (uitableview*) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath
Also returns the contents of each row displayed cannot return nil.
Vii. Deleting a model in an array does not mean releasing the model.
In step two above, the model is simply destroyed from the array, and the model is not sold.
Eight, the Stroyboard is shown in the root view is UIView, and Stroyboard Controller is Uitableviewcontroller will report this error
The reason: The Uitableviewcontroller controller cannot load UITableView because it will load UIView in Stroyboard.
Solution: Change the UIView in Stroyboard to UITableView
Ix. property naming conflicts for custom views
When you find that the xib you describe is not the same as when you are running it, it is time to think of a conflict between the name of the property and the system name that you named.
Cause of Error:
The UITableViewCell of the system comes with the ImageView attribute, so it conflicts.
Workaround: Change the ImageView property name for the custom view to IconView.
Note: Do not customize property names in the future with the same property name as the system itself.
X. LINK Error
Later see duplicate this word, the wrong reason is the repetition defines the class, the function method and so on.
generally because the. m file was imported
Error:
Workaround: Delete the #import "NEWSCELL.M" line.
iOS FAQs (4)