1. Create an empty application project
Create an OC file (uitableviewcontroller) named homeviewcontroller
2. Declare the global variable nsarray * dataarray in homeviewcontroller. h;
3. Add in homeviewcontroller. mCode
-(Void) viewdidload
{
[Super viewdidload];
// Array Initialization
Dataarray = [[nsarray alloc] initwithobjects: @ "A", @ "B", @ "C", @ "D", nil];
// Nslog (@ "the third element of the array: % d", dataarray [2]);
Nslog (@ "the third element of the array: % @", [dataarray objectatindex: 2]);
}
-(Void) viewdidload
{
[Super viewdidload];
// Array Initialization
Dataarray = [[nsarray alloc] initwithobjects: @ "A", @ "B", @ "C", @ "D", nil];
// Nslog (@ "the third element of the array: % d", dataarray [2]);
Nslog (@ "the third element of the array: % @", [dataarray objectatindex: 2]);
}
4. modify the code in appdelegate. M:
In method-(bool) Application:, add:
Homeviewcontroller * homeviewcontroller;
Homeviewcontroller = [[homeviewcontroller alloc] initwithstyle: uitableviewstyleplain];
Self. Window. rootviewcontroller = homeviewcontroller;
// Memory Management
[Homeviewcontroller release];
5. The operation is successful!