更新 0
您的意思是更改所有deals
to_deals
和所有iboards
to_iboards
并添加以下方法,然后在方法末尾调用它processPbn
吗?如果是这样,呼叫是什么样的?
- (id)initWithName:(NSInteger )_iboard deals:(NSArray *)_deals
{
self = [super init];
if (self) {
iboard = _iboard;
deals = _deals;
return self;
}
return nil;
}
更新 0
我想让在中计算的 2 个变量deals
和可在 中使用。我在BSViewController.m的末尾(最后 3 行)的代码中得到以下两个语义问题。iboards
BSViewcontroller
BSdealViewController
"Local declaration of 'deals' hides instance variable"
"Local declaration of 'iboards' hides instance variable"
BSViewController.h
#import <UIKit/UIKit.h>
@interface BSViewController : UIViewController <....>
{
NSInteger iboard;
NSArray *deals;
}
@property (nonatomic) NSInteger iboard;
@property (nonatomic, strong) NSArray *deals;
- (void) processPbn;
@end
BSViewController.m
#import "BSViewController.h"
@interface BSViewController ()
@end
@implementation BSViewController
@synthesize iboard, deals;
- (void) processPbn
{
NSURLRequest *theRequest = [NSURLRequest .....];
[NSURLConnection sendAsynchronousRequest:theRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *connection, NSData *data, NSError *error)
{
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *sp = @" ";
NSArray*deals=@[[@[sp, sp, sp, sp]mutableCopy],[@[sp, sp, sp, sp]mutableCopy],[@[sp, sp, sp, sp]mutableCopy],[@[sp, sp, sp, sp]mutableCopy],[@[sp, sp, sp, sp]mutableCopy],[@[sp, sp, sp, sp]mutableCopy]];
NSString *toMatch = @"...";
int iboard = 0;
NSRegularExpression *regex = [....];
NSUInteger numberOfMatches = [....];
for (NSTextCheckingResult* board in [.....])
{
for (NSUInteger irange = 1; irange < board.numberOfRanges; ++irange)
{
NSRange matchedRange = [board rangeAtIndex: irange];
NSString* tstring = [string substringWithRange: matchedRange];
for (NSUInteger ix = 0; ix < tstring.length; ++ix)
{
NSRange cardInSuit = NSMakeRange(ix, 1);
int seat = (irange-1)/4 ;
int suit = (irange-1)%4 ;
NSString* replace= [deals[iboard][suit] ....];
[deals[iboard] replaceObjectAtIndex: suit withObject: replace];
}
}
++iboard;
}
}];
}
@end
(由于上述原因?)我Use of undeclared identifier 'iboard'
在下面的 NSLog 指令中也遇到了错误。
BSdealViewController.m
#import "BSdealViewController.h"
#import "BSViewController.h"
@interface BSdealViewController ()
@end
- (void)viewDidLoad
{
NSLog(@"iboard : %@", iboard);
}