런타임 중에 NSMutablearray에 모든 RSSI 값을 저장하고 마지막으로 콘솔에 출력하려고합니다. x의 값을 20000으로 변경하여 RSSI의 값에 변화가 있는지 확인합니다 ... 불행히도 변경이 없습니다. Xcode는 RSSI의 20000 값을 코드 시작 부분에서 읽습니다 (이것이 맞는지 확실하지 않음). 샘플링 또는?) 문제. 어떤 도움이라도 대단히 감사하겠습니다.iBeacon RSSI 값을 배열에 저장할 수 없습니다.
rssiArray = [[NSMutableArray alloc] init];
long newBeacon = 0;
if (beacon.rssi == newBeacon)
{
newBeacon = beacon.rssi;
}
else
{
for (int x = 0; x < 1; x++) {
[rssiArray addObject:[NSString stringWithFormat:@"%d", x]];
[rssiArray addObject:@(beacon.rssi)];
}
}
//Send array to console
NSLog (@"%@", [self rssiArray]);
배열이 같은 동일한 파일의 맨 합성 :
어레이는 또한 여기에 정의 ViewController.h
#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "DetailViewController.h"
@interface ViewController()
{
}
@end
@implementation ViewController
@synthesize rssiArray;
:
//array for storing RSSI values
@property (strong, nonatomic) NSMutableArray *rssiArray;
@PaulW
so ...
-
이렇게 ViewController.m의 배열을 초기화 :
그래서 같은 AppDelegate.m 내의 didRangeBeacons 방법에 다음 코드를 붙여 ...
for (int x = 0; x < 500; x++) { [rssiArray addObject:[NSString stringWithFormat:@"%d", x]]; [rssiArray addObject:@(NOTSUREWHATGOESHERE???..WANT TO STORE RSSI)]; } //Send array to console NSLog (@"%@", [self rssiArray]);
- (void)viewDidLoad
{
[super viewDidLoad];
rssiArray = [[NSMutableArray alloc] initWithObjects:nil];
}
(당신이
@synthesize
를 제거하면_rssiArray
을 것)에 액세스 할 수있는 습관을해야 선언이되어@synthesize
지시를 필요로하지 않으며 문맥에 표시된'rssiArray'의? 즉. 이 메소드가 실행될 때마다'rssiArray'를 다시 초기화합니까? 그렇다면 문제가됩니다. 그렇지 않다면 문맥에 전체 메서드 및 배열 선언을 표시하십시오. – Paulw11@ Paulw11 - 질문이 반영되도록 코드가 업데이트되었습니다. 미리 감사드립니다. – pimppatty
그래서 배열을 매번 초기화하는 것처럼 보입니다. 즉, 이전 값을 효과적으로 버리게됩니다. 이 코드는'didRangeBeacons'에 있습니까? – Paulw11