2010-06-09 6 views
0

이 문제에 대한 게시물 모음을 찾았지만 실제로 이러한 경고 메시지 중 하나를 제거 할 수있었습니다.지속성 '<class>'이 + 메서드에 응답하지 않을 수 있습니다.

일부 컨텍스트 : 나는 목표 C를 학습 운동으로 환율 계산기를 만드는거야

내 속도 클래스는 통화는 다음과 같이 또는 외모로 변환 할 수있는 속도를 나타냅니다

:

Rate.h을

// 
// Rate.h 
// Currency Converter 
// 
// Created by Matthew Spence on 08/06/2010. 
// Copyright 2010 __MyCompanyName__. All rights reserved. 
// 

#import <Cocoa/Cocoa.h> 


@interface Rate : NSObject { 
NSString* code; 
NSString* description; 
float rate; 
} 
- (id)init; 
- (id)initTest; 
- (id)initWithCode:(NSString*)code description:(NSString*)description rate:(float)rate; 
@property(retain) NSString* code; 
@property(retain) NSString* description; 
@property(readwrite) float rate; 
@end 

Rate.m

// 
// Rate.m 
// Currency Converter 
// 
// Created by Matthew Spence on 08/06/2010. 
// Copyright 2010 __MyCompanyName__. All rights reserved. 
// 

#import "Rate.h" 


@implementation Rate 
@synthesize code; 
@synthesize description; 
@synthesize rate; 
- (id)init { 
return self; 
} 

- (id)initTest { 
return self; 
} 

- (id)initWithCode:(NSString*)codeA description:(NSString*)descriptionA rate:(float)rateA { 
self.code = codeA; 
self.description = descriptionA; 
self.rate = rateA; 
[self init]; 
return self; 
} 
@end 

경고

Rate *rate = [Rate initWithCode... 

경고 :

'Rate' may not respond to '+initWithCode:description:rate:' 

로 광고에

ExchangeRates.m

// 
// ExchangeRates.m 
// Currency Converter 
// 
// Created by Matthew Spence on 02/06/2010. 
// Copyright 2010 __MyCompanyName__. All rights reserved. 
// 

#import "ExchangeRates.h" 
#import "SynthesizeSingleton.h" 
#import "Rate.h" 
#import "NSString+CVS.h" 


@implementation ExchangeRates 
@synthesize matrix; 
synthesize_singleton(ExchangeRates); 
- (id)init { 

self = [super init]; 
self.matrix = [NSMapTable init]; 
    if (self) { 
    NSError *error = nil; 
    NSString *matrixString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://rss.timegenie.com/forex.txt"] encoding:NSUTF8StringEncoding error:&error]; 
    NSArray *matrixArray = [matrixString csvRows]; 
    for(NSArray *rateArray in matrixArray) { 
     Rate *rate = [Rate initWithCode:[rateArray objectAtIndex:0] description:[rateArray objectAtIndex:1] rate:[rateArray objectAtIndex:2]]; 
     [self.matrix setObject:rate forKey:[rateArray objectAtIndex:0]] ; 
     NSLog(@"my ns string = %@", [rateArray objectAtIndex:0]); 
    } 
    } 

    return self; 
} 
@end 

: ExchangeRates 여기 비율의 매트릭스를 유지하는 단일 클래스 발생 헤더 나 헤더에서 선언되지 않은 메소드가 임포트되지 않기 때문에 정상적으로 이해합니다. 당신이 볼 수 있듯이 나는 둘 다 해냈다.

답변

4

당신은 별표 변수없는 선언에 안

Rate* rate = [[Rate alloc] initWithCode:...]; 
//     ^^^^^ 
+0

같은 ObjC 인스턴스를 초기화해야합니까? (php 배경에서 나오고 포인터의 머리를 둥글게 생각합니다.) – msaspence

+0

@user : 중요하지 않습니다. – kennytm

관련 문제