Commit 4e862a1f authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: use NSArray's firstObject where appropriate

parent 9e783b71
......@@ -361,7 +361,7 @@ static AppleRemote* sharedInstance=nil;
}
- (void) executeClickCountEvent: (NSArray*) values {
AppleRemoteEventIdentifier event = [[values objectAtIndex:0] unsignedIntValue];
AppleRemoteEventIdentifier event = [[values firstObject] unsignedIntValue];
NSTimeInterval eventTimePoint = [[values objectAtIndex:1] doubleValue];
BOOL finishedClicking = NO;
......
......@@ -293,7 +293,7 @@
vlc_object_t *p_object = VLC_OBJECT(getAout());
if (p_object == NULL)
p_object = vlc_object_hold(pl_Get(p_intf));
var_SetString(p_object, "equalizer-preset", [B64DecNSStr([items objectAtIndex:0]) UTF8String]);
var_SetString(p_object, "equalizer-preset", [B64DecNSStr([items firstObject]) UTF8String]);
vlc_object_release(p_object);
/* filter handling */
......
......@@ -221,9 +221,9 @@
[_customize_aud_samplerate_pop removeAllItems];
[_customize_subs_pop removeAllItems];
[_customize_vid_codec_pop addItemsWithTitles:[_videoCodecs objectAtIndex:0]];
[_customize_aud_codec_pop addItemsWithTitles:[_audioCodecs objectAtIndex:0]];
[_customize_subs_pop addItemsWithTitles:[_subsCodecs objectAtIndex:0]];
[_customize_vid_codec_pop addItemsWithTitles:[_videoCodecs firstObject]];
[_customize_aud_codec_pop addItemsWithTitles:[_audioCodecs firstObject]];
[_customize_subs_pop addItemsWithTitles:[_subsCodecs firstObject]];
[_customize_aud_samplerate_pop addItemWithTitle:@"8000"];
[_customize_aud_samplerate_pop addItemWithTitle:@"11025"];
......@@ -246,7 +246,7 @@
[_drop_box enablePlaylistItems];
[_drop_box setDropHandler: self];
[self resetCustomizationSheetBasedOnProfile:[self.profileValueList objectAtIndex:0]];
[self resetCustomizationSheetBasedOnProfile:[self.profileValueList firstObject]];
}
# pragma mark -
......@@ -264,7 +264,7 @@
{
if (b_streaming) {
if ([[[_stream_type_pop selectedItem] title] isEqualToString:@"HTTP"]) {
NSString *muxformat = [self.currentProfile objectAtIndex:0];
NSString *muxformat = [self.currentProfile firstObject];
if ([muxformat isEqualToString:@"wav"] || [muxformat isEqualToString:@"mov"] || [muxformat isEqualToString:@"mp4"] || [muxformat isEqualToString:@"mkv"]) {
NSBeginInformationalAlertSheet(_NS("Invalid container format for HTTP streaming"), _NS("OK"), @"", @"", _window,
nil, nil, nil, nil,
......@@ -541,7 +541,7 @@
NSArray *values = [[paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
if ([values count] > 0) {
[self setMRL: [NSString stringWithUTF8String:vlc_path2uri([[values objectAtIndex:0] UTF8String], NULL)]];
[self setMRL: [NSString stringWithUTF8String:vlc_path2uri([[values firstObject] UTF8String], NULL)]];
[self updateOKButton];
[self updateDropView];
return YES;
......@@ -694,7 +694,7 @@
return;
}
[self selectCellByEncapsulationFormat:[components objectAtIndex:0]];
[self selectCellByEncapsulationFormat:[components firstObject]];
[_customize_vid_ckb setState:[[components objectAtIndex:1] intValue]];
[_customize_aud_ckb setState:[[components objectAtIndex:2] intValue]];
[_customize_subs_ckb setState:[[components objectAtIndex:3] intValue]];
......@@ -924,7 +924,7 @@
if (!b_streaming) {
/* file transcoding */
// add muxer
[composedOptions appendFormat:@"}:standard{mux=%@", [self.currentProfile objectAtIndex:0]];
[composedOptions appendFormat:@"}:standard{mux=%@", [self.currentProfile firstObject]];
// add output destination
[composedOptions appendFormat:@",access=file{no-overwrite},dst=%@}", _outputDestination];
......@@ -937,7 +937,7 @@
else if ([[[_stream_type_pop selectedItem] title] isEqualToString:@"MMSH"])
[composedOptions appendFormat:@":standard{mux=asfh,dst=%@,port=%@,access=mmsh", _outputDestination, [_stream_port_fld stringValue]];
else
[composedOptions appendFormat:@":standard{mux=%@,dst=%@,port=%@,access=http", [self.currentProfile objectAtIndex:0], [_stream_port_fld stringValue], _outputDestination];
[composedOptions appendFormat:@":standard{mux=%@,dst=%@,port=%@,access=http", [self.currentProfile firstObject], [_stream_port_fld stringValue], _outputDestination];
if ([_stream_sap_ckb state])
[composedOptions appendFormat:@",sap,name=\"%@\"", [_stream_channel_fld stringValue]];
......
......@@ -576,7 +576,7 @@
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (count == 1 && p_input) {
int i_result = input_AddSubtitleOSD(p_input, [[o_values objectAtIndex:0] UTF8String], true, true);
int i_result = input_AddSubtitleOSD(p_input, [[o_values firstObject] UTF8String], true, true);
vlc_object_release(p_input);
if (i_result == VLC_SUCCESS)
return YES;
......
......@@ -136,7 +136,7 @@
/* check whether the user runs OSX with a RTL language */
NSArray* languages = [NSLocale preferredLanguages];
NSString* preferredLanguage = [languages objectAtIndex:0];
NSString* preferredLanguage = [languages firstObject];
if ([NSLocale characterDirectionForLanguage:preferredLanguage] == NSLocaleLanguageDirectionRightToLeft) {
msg_Dbg(VLCIntf, "adapting interface since '%s' is a RTL language", [preferredLanguage UTF8String]);
......
......@@ -491,7 +491,7 @@ static VLCMainWindow *sharedInstance = nil;
}
if ([[self.videoView subviews] count] > 0)
[self makeFirstResponder: [[self.videoView subviews] objectAtIndex:0]];
[self makeFirstResponder: [[self.videoView subviews] firstObject]];
}
......
......@@ -577,7 +577,7 @@
input_thread_t *p_input = playlist_CurrentInput(p_playlist);
if (count == 1 && p_input) {
int i_result = input_AddSubtitleOSD(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true, true);
int i_result = input_AddSubtitleOSD(p_input, vlc_path2uri([[o_values firstObject] UTF8String], NULL), true, true);
vlc_object_release(p_input);
if (i_result == VLC_SUCCESS)
return YES;
......
......@@ -711,7 +711,7 @@ NSString * const PXSLDeleteKeyPressedOnRowsNotification = @"PXSourceListDeleteKe
NSInteger row = [self rowForItem:item];
//Return the default table column
return [[[self tableColumns] objectAtIndex:0] dataCellForRow:row];
return [[[self tableColumns] firstObject] dataCellForRow:row];
}
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
......
......@@ -281,7 +281,7 @@ NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
ProcessSerialNumber mySerial, topSerial;
GetCurrentProcess(&mySerial);
[[_mediaKeyAppList objectAtIndex:0] getValue:&topSerial];
[[_mediaKeyAppList firstObject] getValue:&topSerial];
Boolean same;
OSErr err = SameProcess(&mySerial, &topSerial, &same);
......
......@@ -193,7 +193,7 @@
// cascade windows if we have more than one vout
if (b_multiple_vout_windows) {
if ([o_vout_dict count] == 1) {
NSWindow * o_first_window = [o_vout_dict objectForKey: [[o_vout_dict allKeys] objectAtIndex:0]];
NSWindow * o_first_window = [o_vout_dict objectForKey: [[o_vout_dict allKeys] firstObject]];
NSPoint topleftbase = NSMakePoint(0, [o_first_window frame].size.height);
top_left_point = [o_first_window convertBaseToScreen: topleftbase];
......
......@@ -599,7 +599,7 @@
}
/* filter handling */
NSString *tempString = B64DecNSStr([items objectAtIndex:0]);
NSString *tempString = B64DecNSStr([items firstObject]);
vout_thread_t *p_vout = getVout();
/* enable the new filters */
......
......@@ -149,7 +149,7 @@
@synchronized(self) {
current_anim = self->o_current_animation;
if (!([[[current_anim viewAnimations] objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeOutEffect && [current_anim isAnimating])) {
if (!([[[current_anim viewAnimations] firstObject] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeOutEffect && [current_anim isAnimating])) {
if (current_anim) {
[current_anim stopAnimation];
[anim setCurrentProgress:1.0 - [current_anim currentProgress]];
......@@ -197,7 +197,7 @@
@synchronized(self) {
current_anim = self->o_current_animation;
if (!([[[current_anim viewAnimations] objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeInEffect && [current_anim isAnimating])) {
if (!([[[current_anim viewAnimations] firstObject] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeInEffect && [current_anim isAnimating])) {
if (current_anim) {
[current_anim stopAnimation];
[anim setCurrentProgress:1.0 - [current_anim currentProgress]];
......@@ -227,7 +227,7 @@
{
NSArray *o_subViews = [[self contentView] subviews];
if ([o_subViews count] > 0) {
id o_vout_view = [o_subViews objectAtIndex:0];
id o_vout_view = [o_subViews firstObject];
if ([o_vout_view class] == [VLCVoutView class])
return (VLCVoutView *)o_vout_view;
......@@ -1006,7 +1006,7 @@
- (void)hasBecomeFullscreen
{
if ([[_videoView subviews] count] > 0)
[o_fullscreen_window makeFirstResponder: [[_videoView subviews] objectAtIndex:0]];
[o_fullscreen_window makeFirstResponder: [[_videoView subviews] firstObject]];
[o_fullscreen_window makeKeyWindow];
[o_fullscreen_window setAcceptsMouseMovedEvents: YES];
......@@ -1132,7 +1132,7 @@
[[o_temp_view superview] replaceSubview:o_temp_view with:_videoView];
[_videoView setFrame:[o_temp_view frame]];
if ([[_videoView subviews] count] > 0)
[self makeFirstResponder: [[_videoView subviews] objectAtIndex:0]];
[self makeFirstResponder: [[_videoView subviews] firstObject]];
[_videoView setHidden: b_video_view_was_hidden];
......@@ -1158,7 +1158,7 @@
/* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
viewAnimations = [o_fullscreen_anim2 viewAnimations];
if ([viewAnimations count] >=1 &&
[[[viewAnimations objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect]) {
[[[viewAnimations firstObject] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect]) {
/* Fullscreen ended */
[self hasEndedFullscreen];
} else
......
......@@ -239,11 +239,11 @@
NSArray * components = [[_editTimeTextField stringValue] componentsSeparatedByString:@":"];
NSUInteger componentCount = [components count];
if (componentCount == 1)
pp_bookmarks[i]->i_time_offset = 1000000LL * ([[components objectAtIndex:0] longLongValue]);
pp_bookmarks[i]->i_time_offset = 1000000LL * ([[components firstObject] longLongValue]);
else if (componentCount == 2)
pp_bookmarks[i]->i_time_offset = 1000000LL * ([[components objectAtIndex:0] longLongValue] * 60 + [[components objectAtIndex:1] longLongValue]);
pp_bookmarks[i]->i_time_offset = 1000000LL * ([[components firstObject] longLongValue] * 60 + [[components objectAtIndex:1] longLongValue]);
else if (componentCount == 3)
pp_bookmarks[i]->i_time_offset = 1000000LL * ([[components objectAtIndex:0] longLongValue] * 3600 + [[components objectAtIndex:1] longLongValue] * 60 + [[components objectAtIndex:2] longLongValue]);
pp_bookmarks[i]->i_time_offset = 1000000LL * ([[components firstObject] longLongValue] * 3600 + [[components objectAtIndex:1] longLongValue] * 60 + [[components objectAtIndex:2] longLongValue]);
else {
msg_Err(VLCIntf, "Invalid string format for time");
goto clear;
......
......@@ -208,11 +208,11 @@
[fieldContent componentsSeparatedByString: @":"];
if ([[fieldContent componentsSeparatedByString: @":"] count] == 3) {
timeInSec += ([[ourTempArray objectAtIndex:0] intValue] * 3600); //h
timeInSec += ([[ourTempArray firstObject] intValue] * 3600); //h
timeInSec += ([[ourTempArray objectAtIndex:1] intValue] * 60); //m
timeInSec += [[ourTempArray objectAtIndex:2] intValue]; //s
} else {
timeInSec += ([[ourTempArray objectAtIndex:0] intValue] * 60); //m
timeInSec += ([[ourTempArray firstObject] intValue] * 60); //m
timeInSec += [[ourTempArray objectAtIndex:1] intValue]; //s
}
}
......
......@@ -909,13 +909,13 @@ audio_output_t *getAout(void)
}
}
char *psz_uri = vlc_path2uri([[o_names objectAtIndex:0] UTF8String], NULL);
char *psz_uri = vlc_path2uri([[o_names firstObject] UTF8String], NULL);
// try to add file as subtitle
if ([o_names count] == 1 && psz_uri) {
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
int i_result = input_AddSubtitleOSD(p_input, [[o_names objectAtIndex:0] UTF8String], true, true);
int i_result = input_AddSubtitleOSD(p_input, [[o_names firstObject] UTF8String], true, true);
vlc_object_release(p_input);
if (i_result == VLC_SUCCESS) {
free(psz_uri);
......@@ -1163,7 +1163,7 @@ audio_output_t *getAout(void)
- (void)plItemAppended:(NSArray *)o_val
{
int i_node = [[o_val objectAtIndex:0] intValue];
int i_node = [[o_val firstObject] intValue];
int i_item = [[o_val objectAtIndex:1] intValue];
[[[self playlist] model] addItem:i_item withParentNode:i_node];
......@@ -1274,7 +1274,7 @@ audio_output_t *getAout(void)
- (id)open
{
if (!nib_open_loaded)
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: NSApp];
nib_open_loaded = [NSBundle loadNibNamed:@"Open" owner: o_open];
return o_open;
}
......@@ -1396,7 +1396,7 @@ static const int kCurrentPreferencesVersion = 3;
NSArray *libraries = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);
if (!libraries || [libraries count] == 0) return;
NSString * preferences = [[libraries objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"];
NSString * preferences = [[libraries firstObject] stringByAppendingPathComponent:@"Preferences"];
int res = NSRunInformationalAlertPanel(_NS("Remove old preferences?"),
_NS("We just found an older version of VLC's preferences files."),
......
......@@ -198,7 +198,7 @@ static bool b_old_spaces_style = YES;
- (BOOL)hasMenuBar
{
if (b_old_spaces_style)
return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
return ([self displayID] == [[[NSScreen screens] firstObject] displayID]);
else
return YES;
}
......
......@@ -433,21 +433,21 @@ struct display_info_t
NSUInteger componentCount = [components count];
NSInteger tempValue = 0;
if (componentCount == 1)
tempValue = [[components objectAtIndex:0] intValue];
tempValue = [[components firstObject] intValue];
else if (componentCount == 2)
tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
tempValue = [[components firstObject] intValue] * 60 + [[components objectAtIndex:1] intValue];
else if (componentCount == 3)
tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
tempValue = [[components firstObject] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
if (tempValue > 0)
[o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
componentCount = [components count];
if (componentCount == 1)
tempValue = [[components objectAtIndex:0] intValue];
tempValue = [[components firstObject] intValue];
else if (componentCount == 2)
tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
tempValue = [[components firstObject] intValue] * 60 + [[components objectAtIndex:1] intValue];
else if (componentCount == 3)
tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
tempValue = [[components firstObject] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
if (tempValue != 0)
[o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
}
......@@ -515,7 +515,7 @@ struct display_info_t
{
NSInteger i_selectedDevice = [o_qtk_video_device_pop indexOfSelectedItem];
if (_qtkvideoDevices.count >= 1) {
NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex:0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
NSValue *sizes = [[[_qtkvideoDevices[i_selectedDevice] formatDescriptions] firstObject] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
[o_capture_width_fld setIntValue: [sizes sizeValue].width];
[o_capture_height_fld setIntValue: [sizes sizeValue].height];
......@@ -709,7 +709,7 @@ struct display_info_t
[o_open_panel setPrompt: _NS("Open")];
[o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
if (returnCode == NSFileHandlingPanelOKButton) {
o_file_path = [[[o_open_panel URLs] objectAtIndex:0] path];
o_file_path = [[[o_open_panel URLs] firstObject] path];
[self openFilePathChanged: nil];
}
}];
......@@ -730,7 +730,7 @@ struct display_info_t
[o_open_panel setCanChooseFiles: YES];
[o_open_panel setCanChooseDirectories: NO];
if ([o_open_panel runModal] == NSOKButton) {
o_file_slave_path = [[[o_open_panel URLs] objectAtIndex:0] path];
o_file_slave_path = [[[o_open_panel URLs] firstObject] path];
}
}
if (o_file_slave_path && [o_file_slave_ckbox state] == NSOnState) {
......@@ -945,7 +945,7 @@ struct display_info_t
[o_open_panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.directory"]];
if ([o_open_panel runModal] == NSOKButton) {
NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
NSString *o_path = [[[o_open_panel URLs] firstObject] path];
if ([o_path length] > 0) {
[NSThread detachNewThreadSelector:@selector(scanSpecialPath:) toTarget:self withObject:o_path];
}
......@@ -1380,7 +1380,7 @@ struct display_info_t
[o_open_panel setPrompt: _NS("Open")];
if ([o_open_panel runModal] == NSOKButton) {
o_sub_path = [[[o_open_panel URLs] objectAtIndex:0] path];
o_sub_path = [[[o_open_panel URLs] firstObject] path];
[o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
[o_file_sub_path_fld setStringValue: [o_file_subtitles_filename_lbl stringValue]];
[o_file_sub_path_lbl setHidden: YES];
......
......@@ -334,7 +334,7 @@
if ([urlItems count] == 1)
[finalStreamAddress appendFormat: @"\"%@:%@\"", [self.streamAddressTextField stringValue],[self.streamPortTextField stringValue]];
else {
[finalStreamAddress appendFormat: @"\"%@:%@", [urlItems objectAtIndex:0], [self.streamPortTextField stringValue]];
[finalStreamAddress appendFormat: @"\"%@:%@", [urlItems firstObject], [self.streamPortTextField stringValue]];
NSUInteger itemCount = [urlItems count];
for (NSUInteger x = 0; x < itemCount; x++)
[finalStreamAddress appendFormat: @"/%@", [urlItems objectAtIndex:x]];
......
......@@ -242,7 +242,7 @@
[o_playlist_header setMenu: o_context_menu];
for (NSUInteger i = 0; i < count; i++) {
o_column = [[o_columnArray objectAtIndex:i] objectAtIndex:0];
o_column = [[o_columnArray objectAtIndex:i] firstObject];
if ([o_column isEqualToString:@"status"])
continue;
......@@ -1016,8 +1016,8 @@
NSUInteger mediaListCount = mediaList.count;
if (mediaListCount > 30) {
for (NSUInteger x = 0; x < mediaListCount - 30; x++) {
[mutDict removeObjectForKey:[mediaList objectAtIndex:0]];
[mediaList removeObjectAtIndex:0];
[mutDict removeObjectForKey:[mediaList firstObject]];
[mediaList removefirstObject];
}
}
} else {
......
......@@ -1173,7 +1173,7 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc]; \
[o_open_panel setCanChooseDirectories: b_directory];
[o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) {
NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
NSString *o_path = [[[o_open_panel URLs] firstObject] path];
[o_textfield setStringValue: o_path];
}
}];
......@@ -2168,7 +2168,7 @@ o_moduleenabled = [NSNumber numberWithBool:NO];\
if ([[[o_modulearray objectAtIndex:i] objectAtIndex:2]
boolValue] != NO) {
o_newstring = [o_newstring stringByAppendingString:
[[o_modulearray objectAtIndex:i] objectAtIndex:0]];
[[o_modulearray objectAtIndex:i] firstObject]];
o_newstring = [o_newstring stringByAppendingString:@":"];
}
......
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