我试图将这段代码合并到一个新的(iOS 5)项目中......问题是,我正在使用ARC,它真的不喜欢编写的代码.
我已经能够解决大多数错误,但我遇到了3个错误,我似乎无法弄清楚.
错误#1:
对于unsafe_unretained属性'delegate'的现有ivar'委托'必须是_unsafe_unretained
.H
@interface SKPSMTPMessage : NSObject {
NSOutputStream *outputStream;
NSInputStream *inputStream;
id <SKPSMTPMessageDelegate> delegate;
}
@property(nonatomic, assign) id <SKPSMTPMessageDelegate> delegate;
Run Code Online (Sandbox Code Playgroud)
.M
@synthesize login, pass, relayHost, relayPorts, subject, fromEmail, toEmail, parts, requiresAuth, inputString, wantsSecure, \
delegate, connectTimer, connectTimeout, watchdogTimer, validateSSLChain;
Run Code Online (Sandbox Code Playgroud)
错误#2:
将非本地对象的地址传递给_autoreleasing参数以进行回写
.H
@interface SKPSMTPMessage : NSObject {
NSOutputStream *outputStream;
NSInputStream *inputStream;
id <SKPSMTPMessageDelegate> delegate;
}
Run Code Online (Sandbox Code Playgroud)
.M
[NSStream getStreamsToHostNamed:relayHost port:relayPort inputStream:&inputStream outputStream:&outputStream];
Run Code Online (Sandbox Code Playgroud)
任何指导将不胜感激.
谢谢.
我有三个NSArray,我想将它们全部合并为一个NSDictionary.问题是当我遍历数组并创建字典时,它会覆盖前一个对象.最后我在字典中只有一个对象.我究竟做错了什么?这是我的代码:
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
for(int i=0; i<[array0 count]; i++) {
[dict setObject:[array0 objectAtIndex:i]
forKey:@"one"];
[dict setObject:[array1 objectAtIndex:i] f
orKey:@"two"];
[dict setObject:[array2 objectAtIndex:i]
forKey:@"three"];
}
Run Code Online (Sandbox Code Playgroud)
也许这会澄清我的意思......这是我想要的结果:
{one = array0_obj0, two = array1_obj0, three = array2_obj0},
{one = array0_obj1, two = array1_obj1, three = array2_obj1},
{one = array0_obj2, two = array1_obj2, three = array2_obj2},
etc
Run Code Online (Sandbox Code Playgroud)
谢谢