Objective-C
Objective-C
Transition from MailMan.MxLookupAll to the Chilkat DNS class
Provides instructions for replacing deprecated MxLookupAll method calls with the Chilkat Dns class.Chilkat Objective-C Downloads
#import <CkoMailMan.h>
#import <NSString.h>
#import <CkoStringArray.h>
#import <CkoDns.h>
#import <CkoJsonObject.h>
BOOL success = NO;
CkoMailMan *mailman = [[CkoMailMan alloc] init];
// ...
// ...
NSString *emailAddr = @"joe@example.com";
// ------------------------------------------------------------------------
// The MxLookupAll method is deprecated:
CkoStringArray *sa = [mailman MxLookupAll: emailAddr];
if (mailman.LastMethodSuccess == NO) {
NSLog(@"%@",mailman.LastErrorText);
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using the Chilkat DNS class
CkoDns *dns = [[CkoDns alloc] init];
CkoJsonObject *json = [[CkoJsonObject alloc] init];
// This gets all MX domains for an email address. (Typically one domain.)
// The preferred domain will be at index 0 (see below).
success = [dns Query: @"MX" domain: emailAddr answer: json];
if (success == NO) {
NSLog(@"%@",dns.LastErrorText);
return;
}
int i = 0;
int count_i = [[json SizeOfArray: @"answer.mx"] intValue];
while (i < count_i) {
json.I = [NSNumber numberWithInt: i];
NSString *domain = [json StringOf: @"answer.mx[i].domain"];
NSLog(@"%@",domain);
i = i + 1;
}