所以我试图从我的Java代码中找出如何匹配objective-c中的两个类。
java代码如下:
import java.io.Serializable;
public interface IClient extends Serializable {
String getDeviceID();
void setDeviceID(String id);
String getNickname();
void setNickname(String name);
boolean matches(IClient client);
}
另一类如下:
import xxx.xxx.xxx.interfaces.IClient;
public class Client implements IClient {
private static final long serialVersionUID = 1L;
private String deviceid;
private String nickname;
public Client() {
deviceid = "";
nickname = "";
}
@Override
public String getDeviceID() {
return this.deviceid;
}
@Override
public void setDeviceID(String id) {
this.deviceid = (id == null) ? "" : id.trim();
}
@Override
public String getNickname() {
return this.nickname;
}
@Override
public void setNickname(String name) {
this.nickname = (name == null) ? "" : name.trim();
}
@Override
public boolean matches(IClient client) {
if (client != null) {
if (client == this) {
return true;
}
if (client.getDeviceID().equals(deviceid) && client.getNickname().equals(nickname)) {
return true;
}
}
return false;
}
}
所以我不太明白你将如何转换布尔值,Objective-c atm 上的代码是 IClient ia 协议和 Client 继承它如下:
Client.h
#import <Foundations/Foundation.h>
@protocol IClient <NSObject>
-(NSString*) DeviceID;
-(NSString*) Nickname;
-(BOOL) matches; // dont really know how to do that one
@end
IClient.h
#import <Foundations/Foundation.h>
#import "IClient.h"
@interface Client : NSObject <IClient>
//etc..
@end
欢迎任何帮助。