Commit d9ef7ffb authored by David Cordero's avatar David Cordero

Fix warnings, use private properties instead of private instance variables

parent 2cfee98a
......@@ -21,10 +21,10 @@
#define remotePlaybackReuseIdentifer @"remotePlaybackReuseIdentifer"
@interface VLCRemotePlaybackViewController () <UICollectionViewDataSource, UICollectionViewDelegate, VLCMediaFileDiscovererDelegate>
{
Reachability *_reachability;
NSMutableArray<NSString *> *_discoveredFiles;
}
@property (strong, nonatomic) Reachability *reachability;
@property (strong, nonatomic) NSMutableArray<NSString *> *discoveredFiles;
@property (nonatomic) NSIndexPath *currentlyFocusedIndexPath;
@end
......@@ -49,7 +49,7 @@
[self.cachedMediaCollectionView registerNib:[UINib nibWithNibName:@"VLCRemoteBrowsingTVCell" bundle:nil]
forCellWithReuseIdentifier:VLCRemoteBrowsingTVCellIdentifier];
_reachability = [Reachability reachabilityForLocalWiFi];
self.reachability = [Reachability reachabilityForLocalWiFi];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
......@@ -60,7 +60,7 @@
VLCMediaFileDiscoverer *discoverer = [VLCMediaFileDiscoverer sharedInstance];
discoverer.filterResultsForPlayability = NO;
_discoveredFiles = [NSMutableArray array];
self.discoveredFiles = [NSMutableArray array];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
discoverer.directoryPath = [[searchPaths firstObject] stringByAppendingPathComponent:@"Upload"];
......@@ -113,7 +113,7 @@
[[VLCMediaFileDiscoverer sharedInstance] updateMediaList];
[_reachability startNotifier];
[self.reachability startNotifier];
[self updateHTTPServerAddress];
}
......@@ -121,7 +121,7 @@
{
[super viewWillDisappear:animated];
[_reachability stopNotifier];
[self.reachability stopNotifier];
}
- (void)reachabilityChanged
......@@ -131,7 +131,7 @@
- (void)updateHTTPServerAddress
{
BOOL connectedViaWifi = _reachability.currentReachabilityStatus == ReachableViaWiFi;
BOOL connectedViaWifi = self.reachability.currentReachabilityStatus == ReachableViaWiFi;
self.toggleHTTPServerButton.enabled = connectedViaWifi;
NSString *uploadText = connectedViaWifi ? [[VLCHTTPUploaderController sharedInstance] httpStatus] : NSLocalizedString(@"HTTP_UPLOAD_NO_CONNECTIVITY", nil);
self.httpServerLabel.text = uploadText;
......@@ -167,9 +167,9 @@
{
NSString *cellTitle;
NSUInteger row = indexPath.row;
@synchronized(_discoveredFiles) {
if (_discoveredFiles.count > row) {
cellTitle = [_discoveredFiles[row] lastPathComponent];
@synchronized(self.discoveredFiles) {
if (self.discoveredFiles.count > row) {
cellTitle = [self.discoveredFiles[row] lastPathComponent];
}
}
......@@ -183,8 +183,8 @@
{
NSUInteger ret;
@synchronized(_discoveredFiles) {
ret = _discoveredFiles.count;
@synchronized(self.discoveredFiles) {
ret = self.discoveredFiles.count;
}
self.cachedMediaConeImageView.hidden = ret > 0;
......@@ -223,10 +223,10 @@
}
NSString *ret = nil;
@synchronized(_discoveredFiles) {
@synchronized(self.discoveredFiles) {
NSInteger index = indexPathToDelete.item;
if (index < _discoveredFiles.count) {
ret = _discoveredFiles[index];
if (index < self.discoveredFiles.count) {
ret = self.discoveredFiles[index];
}
}
return ret;
......@@ -253,9 +253,9 @@
}
__block NSString *fileToDelete = nil;
[self.cachedMediaCollectionView performBatchUpdates:^{
@synchronized(_discoveredFiles) {
fileToDelete = _discoveredFiles[indexPathToDelete.item];
[_discoveredFiles removeObject:fileToDelete];
@synchronized(self.discoveredFiles) {
fileToDelete = self.discoveredFiles[indexPathToDelete.item];
[self.discoveredFiles removeObject:fileToDelete];
}
[self.cachedMediaCollectionView deleteItemsAtIndexPaths:@[indexPathToDelete]];
} completion:^(BOOL finished) {
......@@ -269,8 +269,8 @@
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSURL *url;
@synchronized(_discoveredFiles) {
url = [NSURL fileURLWithPath:_discoveredFiles[indexPath.row]];
@synchronized(self.discoveredFiles) {
url = [NSURL fileURLWithPath:self.discoveredFiles[indexPath.row]];
}
VLCMediaList *medialist = [[VLCMediaList alloc] init];
......@@ -285,17 +285,17 @@
#pragma mark - media file discovery
- (void)mediaFilesFoundRequiringAdditionToStorageBackend:(NSArray<NSString *> *)foundFiles
{
@synchronized(_discoveredFiles) {
_discoveredFiles = [NSMutableArray arrayWithArray:foundFiles];
@synchronized(self.discoveredFiles) {
self.discoveredFiles = [NSMutableArray arrayWithArray:foundFiles];
}
[self.cachedMediaCollectionView reloadData];
}
- (void)mediaFileAdded:(NSString *)filePath loading:(BOOL)isLoading
{
@synchronized(_discoveredFiles) {
if (![_discoveredFiles containsObject:filePath]) {
[_discoveredFiles addObject:filePath];
@synchronized(self.discoveredFiles) {
if (![self.discoveredFiles containsObject:filePath]) {
[self.discoveredFiles addObject:filePath];
}
}
[self.cachedMediaCollectionView reloadData];
......@@ -303,8 +303,8 @@
- (void)mediaFileDeleted:(NSString *)filePath
{
@synchronized(_discoveredFiles) {
[_discoveredFiles removeObject:filePath];
@synchronized(self.discoveredFiles) {
[self.discoveredFiles removeObject:filePath];
}
[self.cachedMediaCollectionView reloadData];
}
......
......@@ -18,10 +18,10 @@
#define SettingsReUseIdentifier @"SettingsReUseIdentifier"
@interface VLCSettingsViewController () <UITableViewDataSource, UITableViewDelegate>
{
NSUserDefaults *_userDefaults;
IASKSettingsReader *_settingsReader;
}
@property (strong, nonatomic) NSUserDefaults *userDefaults;
@property (strong, nonatomic) IASKSettingsReader *settingsReader;
@end
@implementation VLCSettingsViewController
......@@ -29,8 +29,8 @@
- (void)viewDidLoad {
[super viewDidLoad];
_userDefaults = [NSUserDefaults standardUserDefaults];
_settingsReader = [[IASKSettingsReader alloc] init];
self.userDefaults = [NSUserDefaults standardUserDefaults];
self.settingsReader = [[IASKSettingsReader alloc] init];
self.automaticallyAdjustsScrollViewInsets = NO;
self.edgesForExtendedLayout = UIRectEdgeAll ^ UIRectEdgeTop;
......@@ -47,38 +47,39 @@
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return _settingsReader.numberOfSections;
return self.settingsReader.numberOfSections;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_settingsReader numberOfRowsForSection:section];
return [self.settingsReader numberOfRowsForSection:section];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingsReUseIdentifier];
if (!cell)
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:SettingsReUseIdentifier];
}
IASKSpecifier *specifier = [_settingsReader specifierForIndexPath:indexPath];
IASKSpecifier *specifier = [self.settingsReader specifierForIndexPath:indexPath];
cell.textLabel.text = [specifier title];
NSString *specifierType = specifier.type;
if ([specifierType isEqualToString:kIASKPSMultiValueSpecifier]) {
NSArray *titles = [specifier multipleTitles];
NSArray *values = [specifier multipleValues];
NSUInteger selectedIndex = [values indexOfObject:[_userDefaults objectForKey:[specifier key]]];
NSUInteger selectedIndex = [values indexOfObject:[self.userDefaults objectForKey:[specifier key]]];
NSUInteger titlesCount = titles.count;
if (selectedIndex < titlesCount)
cell.detailTextLabel.text = [_settingsReader titleForStringId:titles[selectedIndex]];
cell.detailTextLabel.text = [self.settingsReader titleForStringId:titles[selectedIndex]];
else {
selectedIndex = [values indexOfObject:[specifier defaultValue]];
if (selectedIndex < titlesCount)
cell.detailTextLabel.text = [_settingsReader titleForStringId:titles[selectedIndex]];
cell.detailTextLabel.text = [self.settingsReader titleForStringId:titles[selectedIndex]];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else if ([specifierType isEqualToString:kIASKPSToggleSwitchSpecifier]) {
cell.detailTextLabel.text = [_userDefaults boolForKey:[specifier key]] ? NSLocalizedString(@"ON", nil) : NSLocalizedString(@"OFF", nil);
cell.detailTextLabel.text = [self.userDefaults boolForKey:[specifier key]] ? NSLocalizedString(@"ON", nil) : NSLocalizedString(@"OFF", nil);
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.detailTextLabel.text = @"";
......@@ -90,12 +91,12 @@
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [_settingsReader titleForSection:section];
return [self.settingsReader titleForSection:section];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
IASKSpecifier *specifier = [_settingsReader specifierForIndexPath:indexPath];
IASKSpecifier *specifier = [self.settingsReader specifierForIndexPath:indexPath];
NSString *specifierType = specifier.type;
if ([specifierType isEqualToString:kIASKPSMultiValueSpecifier]) {
......@@ -104,19 +105,20 @@
NSUInteger count = [specifier multipleValuesCount];
NSArray *titles = [specifier multipleTitles];
NSValue *currentValue = [_userDefaults objectForKey:[specifier key]] ?: [specifier defaultValue];
NSValue *currentValue = [self.userDefaults objectForKey:[specifier key]] ?: [specifier defaultValue];
NSUInteger indexOfPreferredAction = [[specifier multipleValues] indexOfObject:currentValue];
for (NSUInteger i = 0; i < count; i++) {
id value = [[specifier multipleValues][i] copy];
UIAlertAction *action = [UIAlertAction actionWithTitle:[_settingsReader titleForStringId:titles[i]]
UIAlertAction *action = [UIAlertAction actionWithTitle:[self.settingsReader titleForStringId:titles[i]]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[_userDefaults setObject:value forKey:[specifier key]];
[self.userDefaults setObject:value forKey:[specifier key]];
[self.tableView reloadData];
}];
[alertController addAction:action];
if (i == indexOfPreferredAction)
if (i == indexOfPreferredAction) {
[alertController setPreferredAction:action];
}
}
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
......@@ -126,7 +128,7 @@
[self presentViewController:alertController animated:YES completion:nil];
} else if ([specifierType isEqualToString:kIASKPSToggleSwitchSpecifier]) {
NSString *specifierKey = [specifier key];
[_userDefaults setBool:![_userDefaults boolForKey:specifierKey] forKey:specifierKey];
[self.userDefaults setBool:![self.userDefaults boolForKey:specifierKey] forKey:specifierKey];
[self.tableView reloadData];
} else {
VLCAboutViewController *targetViewController = [[VLCAboutViewController alloc] initWithNibName:nil bundle:nil];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment