我来自前端开发,所以 MVC 和 OOP 仍然让我有些头疼。只是为了向您解释,我向 nodejs 服务器发送了 500 个字典(带有 100 个参数)。问题是我为每个参数和每个字典创建了 ivars。现在我想在我的同步类的同一个头文件中创建一些类,比如一个人类。我可以在标题上做这样的事情:
#import <Foundation/Foundation.h>
#import "GCDAsyncSocket.h"
@class GCDAsyncSocket;
@interface socketDelegate : NSObject<NSStreamDelegate>
{
NSInputStream *inputStream;
NSOutputStream *outputStream;
NSMutableArray *messages;
GCDAsyncSocket *socket;
dispatch_queue_t connectionQueue_;
}
- (void) initNetworkCommunication;
- (void) sendMessage:(NSArray *)message:(int)numberOfContactsToSend;
@end
@interface personInfo: NSObject
@property (nonatomic,weak)NSString*firstName;
@property (nonatomic,weak)NSString*lastName;
@property (nonatomic,weak)NSDictionary*dicToSendWithConctactInfo;
@end
但在实现中我不知道如何处理多个类。就像我在“socketDelegate”类中有一个需要使用 person 类的方法,但它在其中不可用。
实现这一点的最佳方法是什么?