Try this :
iHoldCaseNo will be golbal variable which hold the iHoldCaseNo case no to be execute.
- (IBAction)VideoAds:(id)sender{
int random = iHoldCaseNo;
switch (random)
{
case 0:
{
VungleSDK* sdk = [VungleSDK sharedSDK];
[sdk playAd:self];
iHoldCaseNo=1;
NSLog(@"Case 0 Displayed - Vungle");
}
break;
case 1:
[AdColony playVideoAdForZone:@"APP_ID" withDelegate:nil];
NSLog(@"Case 1 Displayed - AdColony");
iHoldCaseNo=0;
break;
}
}
Or alternate way is to set the sender i.e button tag as 0 or 1 and according to that handle the switch case.
//For setting the tag use.
sender.tag=1 in case 0 and sender.tag=1 in case 1
//to get random no,
int random = sender.tag;