我已经获得了下面的代码集,我可以很好地获得正确的语法。
我试图弄清楚如何将APIItem2 NSObject连接到self.itemAPI片段。
如果我尝试打印APIItem2.title属性,它说它不是NSObject的一部分,但肯定是。
这是整段代码。我也可以提供任何其他文件。
#import "BDChangeApproveController.h"
#import "BDItemChangeDetailAPI.h"
@interface BDChangeApproveController () <NSURLSessionDelegate>
@property (nonatomic, strong) NSURLSession *session;
@property (nonatomic, copy) NSObject *APIItem2;
@end
@implementation BDChangeApproveController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)refreshTextView
{
// set your text view with the api item here
NSLog(self.itemAPI.title,
self.itemAPI.plannedStart,
self.itemAPI.subcategory,
self.itemAPI.service,
self.itemAPI.associatedCi,
self.itemAPI.environment,
self.itemAPI.assignmentGroup,
self.itemAPI.initiator,
self.itemAPI.coordinator,
self.itemAPI.riskLevel,
self.itemAPI.performingGroup,
self.itemAPI.implementationPlan,
self.itemAPI.status,
self.itemAPI.recoveryScope);
self.title = @"Action";
self.coNumberLabel.text = self.itemAPI.changeOrder;
NSMutableString *coDetailsText = [NSMutableString string];
coDetailsText =
[[NSMutableString alloc] initWithFormat:@"Review Change Order details bellow\n====================\n%@ \n================== \nPlanned Start %@\n==================\nSubcategory: %@\n==================\nService: %@\n==================\nAssociated CIs: %@\n==================\nEnvironment CI: %@\n==================\nApproval Group: %@\n==================\nInitiator : %@\n==================\nCoordinator : %@\n==================\nRisk Level : %@\n==================\nPerforming Group : %@\n==================\nImplementation Plan : %@\n==================\nStatus : %@\n==================\nRecovery Plan : %@\n==================\n",
self.itemAPI.title,
self.itemAPI.plannedStart,
self.itemAPI.subcategory,
self.itemAPI.service,
self.itemAPI.associatedCi,
self.itemAPI.environment,
self.itemAPI.assignmentGroup,
self.itemAPI.initiator,
self.itemAPI.coordinator,
self.itemAPI.riskLevel,
self.itemAPI.performingGroup,
self.itemAPI.implementationPlan,
self.itemAPI.status,
self.itemAPI.recoveryScope];
//NSLog(coDetailsText);
self.coDetailsTextView.text = coDetailsText;
NSLog(@"End of the call and fill");
}
- (void)fetchFeedAPIChangeDetail
{
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
_session = [NSURLSession sessionWithConfiguration:config
delegate:nil
delegateQueue:nil];
NSString *requestString1 = @"http://url.com";
NSURL *url = [NSURL URLWithString:requestString1];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
NSURLSessionDataTask *dataTask =
[self.session dataTaskWithRequest:req
completionHandler:
^(NSData *data, NSURLResponse *response, NSError *error){
NSDictionary *jsonObject1 = [NSJSONSerialization JSONObjectWithData:data
options:0
error:nil];
//NSLog(@"%@", jsonObject1);
self.APIItem2 = jsonObject1[@"CoDetail"];
NSLog(@"%@", self.APIItem2);
[self performSelectorOnMainThread:@selector(refreshTextView) withObject:nil waitUntilDone:NO];
}];
[dataTask resume];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self fetchFeedAPIChangeDetail];
//self.recipeImageView.image = [UIImage imageNamed:self.recipe.image];
NSLog(@"End of ViewDidLoad");
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end