내 NSData 클래스의 UIViewController에있는 모든 레이블, 슬라이더 및 스위치에 액세스 할 수 없습니다.NSObject 클래스에서 UISwitch 상태 변경
FirstViewController.h
@interface FirstViewController : UIViewController
@property (strong) IBOutlet UISwitch * mySwitch;
@property (strong) IBOutlet UISlider *myTransitionSlide;
@property (nonatomic,retain) IBOutlet UILabel *labelTest;
myNSDataClass.h
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@class FirstViewController;
@interface myNSDataClass : NSObject <UIApplicationDelegate,CBPeripheralManagerDelegate>
{
FirstViewController *firstViewController;
}
@property (nonatomic, retain) FirstViewController *firstViewController;
myNSDataClass.m
이 지금까지 내 코드입니다
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray *)requests
{
self.firstViewController = [[FirstViewController alloc]init];
[[self.firstViewController labelTest]setText:@"text changed"];
[self.firstViewController.myTransitionSlide setValue:1];
[self.firstViewController.mySwitch setOn:NO animated:YES];
}
문제는 FirstViewController의 재 할당에서 비롯된 것으로 알고 있지만 무엇을해야할지 모르겠습니다.
이것은 가장 깨끗한 해결책입니다. 고맙습니다. –