Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

iphone - Bad receiver type UIRectEdge and Multiple methods named

I recover this code from disk and try build it on xcode 5.0.2 for ios. In xcode 4 this code work but actually not:

else {


    for (int i=0;i<pieceNumber;i++){

        for (int j=0;j<pieceNumber;j++){

            CGRect rect = CGRectMake( 0, 0, SHAPE_QUALITY*piceSize, SHAPE_QUALITY*piceSize);

            PieceView *piece = [[PieceView alloc] initWithFrame:rect];
            piece.delegate = self;
            piece.image = [array objectAtIndex:j+pieceNumber*i];
            piece.number = j+pieceNumber*i;
            piece.size = piceSize;
            piece.position = -1;
            NSNumber *n = [NSNumber numberWithInt:NumberSquare];
            piece.neighbors = [[NSArray alloc] initWithObjects:n, n, n, n, nil];

            //piece.frame = rect;


            NSMutableArray *a = [[NSMutableArray alloc] initWithCapacity:4];

            for (int k=0; k<4; k++) {
                int e = arc4random_uniform(3)+1;

                if (arc4random_uniform(2)>0) {
                    e *= -1;
                }

                [a addObject:[NSNumber numberWithInt:e]];
            }

            if (i>0) {
                int l = [arrayPieces count]-pieceNumber;
                int e = [[[[arrayPieces objectAtIndex:l] edges] objectAtIndex:1] intValue];
                [a replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:-e]];
                //DLog(@"e = %d", e);
            }

            if (j>0) {
                int e = [[[[arrayPieces lastObject] edges] objectAtIndex:2] intValue];
                [a replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:-e]];
                //DLog(@"e = %d", e);
            }

            if (i==0) {
                [a replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:0]];
            }
            if (i==pieceNumber-1) {
                [a replaceObjectAtIndex:1 withObject:[NSNumber numberWithInt:0]];
            }
            if (j==0) {
                [a replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:0]];
            }
            if (j==pieceNumber-1) {
                [a replaceObjectAtIndex:2 withObject:[NSNumber numberWithInt:0]];
            }


            piece.edges = [NSArray arrayWithArray:a];                

            [arrayPieces addObject:piece];

        }
    }

} //end if loadingGame   

Errors:

Multiple methods named 'edges' found with mismatched result, parameter type or attributes

and

Bad receiver type 'UIRectEdge' (aka 'enum UIRectEdge')

Someone can help me?

Regards,


Code with UIRectEdge

#import <UIKit/UIGeometry.h>
#import <UIKit/UIPanGestureRecognizer.h>

/*! This subclass of UIPanGestureRecognizer only recognizes if the user slides their finger
    in from the bezel on the specified edge. */
NS_CLASS_AVAILABLE_IOS(7_0) @interface UIScreenEdgePanGestureRecognizer : UIPanGestureRecognizer
@property (readwrite, nonatomic, assign) UIRectEdge edges; //< The edges on which this gesture recognizes, relative to the current interface orientation
@end

and with edges problem

//@property (nonatomic, assign) id<PieceViewProtocol> delegate;
@property (nonatomic, assign) PuzzleController *delegate;


@property(nonatomic, retain) NSArray *edges;
@property(nonatomic, retain) NSArray *neighbors;
@property(nonatomic, retain) UIImage *image;
@property(nonatomic, retain) UIView *centerView;
@property(nonatomic, retain) UIPanGestureRecognizer *pan;

@property(nonatomic, retain) GroupView *group;

@property(nonatomic) BOOL isPositioned;
@property(nonatomic) BOOL isLifted;
@property(nonatomic) BOOL isFree;
@property(nonatomic) BOOL isRotating;
@property(nonatomic) BOOL isBoss;
@property(nonatomic) BOOL hasNeighbors;

@property(nonatomic) CGPoint oldPosition;

@property(nonatomic) int number;
@property(nonatomic) int position;
@property(nonatomic) int positionInDrawer;
@property(nonatomic) int moves;
@property(nonatomic) int rotations;

@property(nonatomic) float angle;
@property(nonatomic) float size;
@property(nonatomic) float padding;
@property(nonatomic) float tempAngle;



- (void)move:(UIPanGestureRecognizer*)gesture;
- (void)rotate:(UIRotationGestureRecognizer*)gesture;
- (void)rotateTap:(UITapGestureRecognizer*)gesture;

- (id)initWithFrame:(CGRect)frame;
- (int)edgeNumber:(int)i;
- (void)setNeighborNumber:(int)i forEdge:(int)edge;
- (NSArray*)allTheNeighborsBut:(NSMutableArray*)excluded;
- (CGPoint)realCenter;
- (void)pulse;
- (BOOL)isCompleted;

@end
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess your project is originally from https://github.com/AndreaBarbon/Puzzle-iOS

What I did to get it running in Xcode 5.0.2 was to search the whole project for "edges" and replace every instance with "my_edges" (without quotes) and then it worked.

As rmaddy pointed out, "edges" has been added to the uikit in iOS7, that is why you get the error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...