I am uploading video from my app to YouTube. I have this completed, but there is a small hitch. I use picker to allow the user to select the category of the video. I am trying to use the categories listed by Apple in their upload page which includes items such as "Autos & Vehicles". However if you look at the categories accepted by YouTube this one is "Autos". To deal with this I create the Array for the Picker using "Autos & Vehicles" but then later I convert these to "Autos".
I do this using the following code.
pickerArray = [[NSMutableArray alloc ]init ];
[pickerArray addObject: @"Autos & Vehicles" ];
[pickerArray addObject:@"Comedy"];
[pickerArray addObject:@"Education"];
[pickerArray addObject:@"Entertainment"];
[pickerArray addObject:@"Film & Animation"];
[pickerArray addObject:@"Gaming"];
[pickerArray addObject:@"Howto & Style"];
[pickerArray addObject:@"Music"];
[pickerArray addObject:@"News & Politics"];
[pickerArray addObject:@"Nonprofits & Activism"];
[pickerArray addObject:@"People & Blogs"];
[pickerArray addObject:@"Pets & Animals"];
[pickerArray addObject:@"Science & Technology"];
[pickerArray addObject:@"Sports"];
[pickerArray addObject:@"Travel & Events"];
[catagoryPicker selectRow:1 inComponent:0 animated:NO];
catagoryField1.text = [pickerArray objectAtIndex:[catagoryPicker selectedRowInComponent:0]];
//and then to convert this code
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
catagoryField1.text = [pickerArray objectAtIndex:row];
if (catagoryField1.text == @"Comedy") {
catagoryField.text =@"Comedy";
}
else if (catagoryField1.text == @"Autos & Vehicles") {
catagoryField.text =@"Autos";}
else if (catagoryField1.text == @"Gaming") {
catagoryField.text =@"Games";}
else if (catagoryField1.text == @"Education") {
catagoryField.text =@"Education";}
else if (catagoryField1.text == @"Entertainment") {
catagoryField.text =@"Entertainment";}
else if (catagoryField1.text == @"Film & Animation") {
catagoryField.text =@"Film";}
else if (catagoryField1.text == @"Howto & Style") {
catagoryField.text =@"Howto";}
else if (catagoryField1.text == @"Music") {
catagoryField.text =@"Music";}
else if (catagoryField1.text == @"News & Politics") {
catagoryField.text =@"News";}
else if (catagoryField1.text == @"Nonprofits & Activism") {
catagoryField.text =@"Nonprofit";}
else if (catagoryField1.text == @"People & Blogs") {
catagoryField.text =@"People";}
else if (catagoryField1.text == @"Pets & Animals") {
catagoryField.text =@"Animals";}
else if (catagoryField1.text == @"Science & Technology") {
catagoryField.text =@"Tech";}
else if (catagoryField1.text == @"Sports") {
catagoryField.text =@"Sports";}
else if (catagoryField1.text == @"Travel & Events") {
catagoryField.text =@"Travel";}
}
This works when there is only a single word like "Gaming" but it doesn't work when using "Autos & Vehicles". If I use "Autos / Vehicles" it doesn't work but "Autos/Vehicles" does. So I am assuming that the use of spaces messes something up. Can someone tell me how to fix this so I can use "Autos & Vehicles".
Thanks
This is explained at https://developers.google.com/youtube/2.0/reference#YouTube_Category_List
Basically, each category has a term
value (which is what you pass in to the API) and a label
value (which is what you show in your UI). Those docs explain how to retrieve a list of those values in an XML file and how to determine what to show.