开发者

Selector element does not have valid object type (Cocoa touch)

I'm trying to iterate over a collection of objects and create an annotation for each object as seen in this code, but at the closing } of the for loop i get this error Selector element does not have valid object type. What does this mean?

    for (POI myPOI in appDelegate.pois){
        CLLocationCoordinate2D location;
        location.latitude=[myPOI.lat doubleValue];
        location.longitude=[myPOI.lon doubleValue];
        region.span=span;
        region.center=location;

        LocationAnnotation *locAnn;

        locAnn = [[LocationAnnotation alloc] initWithCoordi开发者_如何学Cnate:location];
        [mapView addAnnotation:locAnn];
        [mapView setRegion:region animated:YES];

        [locAnn release];
    }

Also i get Variable sized object cannot be initialized at the beginning of the loop. And, instance variable lat (and lon too) is declared protected.

What have i done wrong?

Thanks


Is "POI" an object? If so, you're not declaring "myPOI" as a pointer to a POI. You'll want:

POI * myPOI ...

If POI is not an object, you can't use fast enumeration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜