I found a lot of example but still I could not success to show a dynamically created MKPolygon on the MKMapView. I have a SQLite db which has coordinates for polygons. I want to read coordinates from db and then create a polygon. It should not be difficult.
First I'm reading the row then I calculate the number of coordinate in record (dbCount) then I'm creating an array like this :
CLLocationCoordinate2D *dbCoord = (CLLocationCoordinate2D *) malloc(sizeof(CLLocationCoordinate2D) * dbCount);
then in a for loop I'm filling coordinates into dbCoord array like this :
for (something) {
CLLocationCoordinate2D latLon;
latLon.latitude = latFromDb;
latLon.longitude = lonFromDb;
dbCoord[recCounter] = latLon;
recCounter++
}
but dbCoord array didn't contain all coordinates. recCounter is increasing each loop but there is only one item in this array.
finally I found it! the reason is definition of dbCoord
I've added
@property (nonatomic, readonly) CLLocationCoordinate2D *dbCoord;
line into .h file and my code is working now