简体   繁体   中英

[iOS][Objective-C] Expected type

I have a Problem in one of my Objective-C classes.

Xcode said that there is a Parse Issue in line 20.

+ (Boolean)hasOverlay:(KnownPoints*)points byPoint:(CGPoint)p;

KnownPoints is a self written Class. Xcode displays that the error is at the part '(KnownPoints*)points.

The answer of an other similar topic to add this Codeline:

@class KnownPoints

does not work.

The class is called in a calculation class which makes latitudes and longitudes to x and y coordiantes form a view.

Here the Code: (CalcMakerPos.h)

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import "Journey.h"
#import "CoordRect.h"
#import "KnownPoints.h"


@interface CalcMakerPos : NSObject


+ (CGPoint)calcPosFor: (CLLocationCoordinate2D)coord WithDataFrom: (CoordRect*)rect     AtView: (UIView*)view;
+ (Boolean)hasOverlay:(KnownPoints*)points byPoint:(CGPoint)p;
@end

CalcMakerPos.m

#import "CalcMakerPos.h"
#import "MinMaxCoords.h"
#import "Journey.h"
#import "KnownPoints.h"

@implementation CalcMakerPos
#pragma mark Calculate GeoCoords zu Pixeln
+ (CGPoint)calcPosFor: (CLLocationCoordinate2D)coord WithDataFrom: (CoordRect*)rect AtView: (UIView*)view{

     double maxLat = [rect maxLat];
     double minLat = [rect minLat];
     double maxLon = [rect maxLon];
     double minLon = [rect minLon];
     int x = (int)((coord.longitude - minLon) / (maxLon - minLon) * view.frame.size.width);
     int y = (int)((coord.latitude - minLat) / (maxLat - minLat) * view.frame.size.height);
     NSLog(@"Point(%d, %d)", x,y);
     return CGPointMake(x, y);
}

#pragma mark check whether point is free
+ (Boolean)hasOverlay:(KnownPoints*)points byPoint:(CGPoint)p{
    BOOL isOverLay = false;

    return isOverLay;
}
@end

I hope you can help me.

Greetings form Germany

Robybyte

KnownPoints and Journey are being imported twice. Remove the imports from the implementation file because they are redundant.

Clean and build your project after that.

This could be caused by circular import statements.

Make sure that CalcMakerPos is not imported or added as @class into KnownPoints .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM