drawrect 함수에서 그래픽을 그릴 수있는 사용자 정의 뷰가 있습니다.내포 된 함수는 drawrect 문제에서 허용되지 않습니다.
그러나 setNeedsDisplay를 수행하기 전에 배열의 컨텍스트를 기반으로 그리기를 원합니다. drawRect 함수에서 drawRect와 함께 NSString 또는 NSarray를 사용하면 이해가 안되는 중첩 함수 오류가 발생합니까?
@property (nonatomic, copy) NSArray *nary;
NSArray *ns = [nary objectAtIndex:0];
또한 거의 직접 객체를 기록 안 : 당신은 별표 필요
// MyView.h
#import <UIKit/UIKit.h>
@interface MyView : UIView {
}
@end
// MyView.m
#import "MyView.h"
@implementation MyView
CGContextRef c;
CGFloat black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}
- (void)drawRect:(CGRect)rect {
c = UIGraphicsGetCurrentContext();
CGContextSetStrokeColor(c, black);
//Gives a nested functions are disabled error at compiletime
NSString nsz * = @"test";
}
- (void)dealloc {
[super dealloc];
}
@end
@ Joe 할 수는 있지만 권장하지 않습니다. 'nary'가 형식 지정자 ('% @'와 같은)를 포함하는 문자열이면,'NSLog()'는 실제 객체가 아닌 스택에서 데이터를 읽으려고 시도 할 것이고 여러분은 충돌 할 것입니다. 하지만 여전히 * 가능합니다. –
NSLog는 코드에서 찾을 수 있도록 어레이의 데이터를 볼 수 있었지만 NSLog의 오류는 없었습니다. – Martin
메일에 다른 PC를 사용하고있었습니다. 하지만 지금은/Users/martinstave/Documents/windowIpadOne /../../ 다운로드/iPhoneLine/MyView.m : 134 : 0 /Users/martinstave/Documents/windowIpadOne/../../Downloads/iPhoneLine/MyView가 아닙니다. m : 134 : error : 중첩 된 함수가 비활성화되었습니다. 다시 활성화 할 수 있도록 -fnested-functions을 사용합니다. – Martin