Encerrado

UIAlertView Download Confirmation message

I am trying to program a view that allows the user to press a button which asks the user if they are sure they want to download the ring with an alertview and then if they press "yes download" another alertview pops up with a confirmation message. I will send you what I have for my .m file if you are interested. It should only take an hour to do because it is relatively simple.

Everytime I get the alert to pop up and I click the yes download button the app crashes. Here is the code you will be working on:


.h file

#import <UIKit/UIKit.h>
#import <AVfoundation/AVAudioPlayer.h>
#import <AudioToolbox/AudioToolbox.h>



@interface ThirdViewController : UIViewController <UIAlertViewDelegate> {
AVAudioPlayer *audioplayer;

}

@property (nonatomic, retain) IBOutlet UIButton *btn1;
@property (nonatomic, retain) IBOutlet UIButton *btn2;
@property (nonatomic, retain) IBOutlet UIButton *btn3;
@property (nonatomic, retain) IBOutlet UIButton *btn4;
@property (nonatomic, retain) IBOutlet UIButton *btn5;
@property (nonatomic, retain) IBOutlet UIButton *btn6;
@property (nonatomic, retain) IBOutlet UIButton *btn7;
@property (nonatomic, retain) IBOutlet UIButton *btn8;
@property (nonatomic, retain) IBOutlet UIButton *btn9;
@property (nonatomic, retain) IBOutlet UIButton *btn10;

-(IBAction)saveRing:(UIButton*)sender;





.m file


import "AVFoundation/AVAudioPlayer.h"


@implementation ThirdViewController
@synthesize btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10;


-(IBAction)saveRing:(UIButton*)sender {
// Get the path to the Documents Directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// Detect which button was tapped and set up the file to save
NSString *filePath;
NSString *fileName;
if (sender.tag == 1){
filePath = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"m4r"];
fileName = @"Carol Bells.m4r";
} else if (sender.tag == 2){
filePath = [[NSBundle mainBundle] pathForResource:@"sound2" ofType:@"m4r"];
fileName = @"Realms Glory.m4r";
}
else if (sender.tag == 3){
filePath = [[NSBundle mainBundle] pathForResource:@"sound3" ofType:@"m4r"];
fileName = @"Jingle Bells.m4r";
}
else if (sender.tag == 4){
filePath = [[NSBundle mainBundle] pathForResource:@"sound4" ofType:@"m4r"];
fileName = @"Jingle Bells2.m4r";
}
else if (sender.tag == 5){
filePath = [[NSBundle mainBundle] pathForResource:@"sound5" ofType:@"m4r"];
fileName = @"Herald Angels.m4r";
}
else if (sender.tag == 6){
filePath = [[NSBundle mainBundle] pathForResource:@"sound6" ofType:@"m4r"];
fileName = @"The Bells.m4r";
}
else if (sender.tag == 7){
filePath = [[NSBundle mainBundle] pathForResource:@"sound7" ofType:@"m4r"];
fileName = @"Sugar Plum.m4r";
}
else if (sender.tag == 8){
filePath = [[NSBundle mainBundle] pathForResource:@"sound8" ofType:@"m4r"];
fileName = @"Wish You Merry.m4r";
}
else if (sender.tag == 9){
filePath = [[NSBundle mainBundle] pathForResource:@"sound9" ofType:@"m4r"];
fileName = @"Clear.m4r";
}
else if (sender.tag == 10){
filePath = [[NSBundle mainBundle] pathForResource:@"sound10" ofType:@"m4r"];
fileName = @"Deck The Halls.m4r";
}

NSString *m4rPath = [documentsDirectory stringByAppendingPathComponent:fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];

// Detect if the file already exists
BOOL fileExists = [fileManager fileExistsAtPath:m4rPath];


if (fileExists) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:fileName message:@"The selected file already exists. Sync to iTunes to finish loading the file." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];

[alert show];

}

else {
// Notify of the option
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:fileName message:@"Are you sure you want to save this ringtone?" delegate:self cancelButtonTitle:@"Not Now"
otherButtonTitles:@"Yes Download", nil] autorelease];

[alert show];

}

}




-(void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

// Get the path to the Documents Directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// Detect which button was tapped and set up the file to save
NSString *filePath;
NSString *fileName;


NSString *m4rPath = [documentsDirectory stringByAppendingPathComponent:fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];

if (buttonIndex == 1) {


if (btn1.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"m4r"];
fileName = @"Carol Bells.m4r";
} else if (btn2.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound2" ofType:@"m4r"];
fileName = @"Realms Glory.m4r";
}
else if (btn3.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound3" ofType:@"m4r"];
fileName = @"Jingle Bells.m4r";
}
else if (btn4.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound4" ofType:@"m4r"];
fileName = @"Jingle Bells2.m4r";
}
else if (btn5.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound5" ofType:@"m4r"];
fileName = @"Herald Angels.m4r";
}
else if (btn6.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound6" ofType:@"m4r"];
fileName = @"The Bells.m4r";
}
else if (btn7.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound7" ofType:@"m4r"];
fileName = @"Sugar Plum.m4r";
}
else if (btn8.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound8" ofType:@"m4r"];
fileName = @"Wish You Merry.m4r";
}
else if (btn9.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound9" ofType:@"m4r"];
fileName = @"Clear.m4r";
}
else if (btn10.selected){
filePath = [[NSBundle mainBundle] pathForResource:@"sound10" ofType:@"m4r"];
fileName = @"Deck The Halls.m4r";
}
// Save the file
[fileManager copyItemAtPath:filePath toPath:m4rPath error:nil];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:fileName message:@"File Saved. You must sync your device to iTunes to finish loading. For complete instructions, swipe left." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];

[alert show];

}


}






- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.




btn1.tag = 1;
btn2.tag = 2;
btn3.tag = 3;
btn4.tag = 4;
btn5.tag = 5;
btn6.tag = 6;
btn7.tag = 7;
btn8.tag = 8;
btn9.tag = 9;
btn10.tag = 10;

Habilidades: Vale Tudo, iPad, iPhone, Mobile App Development, Objective C

Ver mais: view my message, send message phone, download button, send confirmation message email php, oscommerce send confirmation email, send confirmation email aspnet using shopping cart, joomla payment send confirmation email, send confirmation emails cron job, attach file email confirmation joomla, virtuemart doesnt send confirmation, spring file upload confirmation message, drupal ecommerce doesnt send confirmation email, virtuemart doesnt send confirmation email admin

Acerca do Empregador:
( 5 comentários ) Charlotte, United States

ID do Projeto: #6829458

22 freelancers estão ofertando em média $16/hora para este trabalho

qitsol

A proposal has not yet been provided

$21 USD / hora
(50 Comentários)
8.0
beepig

Hi there, I'm a mobile applications development team manager and a developer myself too, and I'm very interested in your job post involving these skills. Please see our team on blog: [url removed, login to view] Mais

$11 USD / hora
(103 Comentários)
7.9
monster816

Dear sir How are you? I've saw your job posting carefully with interested. I've looked your bugs... I think that your bug is problem on memory management. I can complete your job in 2~3 days. Thanks for your ti Mais

$47 USD / hora
(25 Comentários)
7.2
XcodePro492

Hi, I am experienced developer with 5 years of experience in Mobile Technologies, Especially iOS & Android. I work on iOS Myself & my team work for iOS & Android. I manage small team of local developers. We have com Mais

$15 USD / hora
(59 Comentários)
6.9
kantisuthar

Hi, Let us DISCUSS. Please DO NOT award your project DIRECTLY. We are serious bidder and keenly interested in your project. We are group of Freelancers but not a Company. Please review our profile once. Thanks.

$8 USD / hora
(105 Comentários)
6.5
NiceProgram

Hello, Over the years I have built a high reputation for satisfactory yet competitive service. My services stick and run to schedule. I will stock sufficiently varied types of clients goods to satisfy the most exac Mais

$15 USD / hora
(46 Comentários)
6.4
sukhpalpunni

I will fix this in 50$. iOS: [url removed, login to view] [url removed, login to view] [url removed, login to view] Mais

$12 USD / hora
(32 Comentários)
6.2
aistechnolabs

Hi, We have gone through your requirement and we understand that you are looking for highly skilled, qualified, and experience Mobile development team for your project. I am glad to say we have worked on ma Mais

$25 USD / hora
(2 Comentários)
5.5
dingxudong

Hi! I have seen your description I can do this job perfectly. If you want a good result, please reply to me I will wait your good response Thanks

$52 USD / hora
(6 Comentários)
5.4
sunnysmile911

Hi, I read the post of your project very carefully and I can do it well. I have over 5 years experience and high skills for mobile apps and web. Also I have several iOS(iPhone and iPad) devices for testing Pl Mais

$15 USD / hora
(9 Comentários)
5.2
sure4app

I am Vinny, Mobile Application Developer. I have 4+ years of Exp in the same field and my applications are available in both App Store and Android Market. I have keen knowledge on : XCode, Objective-C, Cocoas, Titanium Mais

$8 USD / hora
(9 Comentários)
4.8
liangfang

How do you do? It's nice to see you. Well, your project takes my attention because it sounds good to me. In other words, it's piece of cake. It's a snap. You could know a lot about me seeing my profile and my hist Mais

$12 USD / hora
(4 Comentários)
4.5
Jeetgiri

Hello Sir, I have more than 3.5 years of exp. in IOS application development in an IT company and I have deployed more than 20 apps on App store on behalf of my Company. Right now, I have started work as a freel Mais

$12 USD / hora
(11 Comentários)
4.0
songhe

Dear sir, I have excellent skills and great experiences in iphone app development. I have expertise knowledge of objective-c what is basic programming language in ios app development. You can confirm my skills on Mais

$12 USD / hora
(3 Comentários)
3.6
khuntpm

Dear Sir, We are working on Web, iPhone, iPad and Android. We have large team of that skills with designer. We have checked your requirement and we are interested to working on it, would like to see wire-frame for m Mais

$10 USD / hora
(7 Comentários)
3.1
Lgwebsol

Hope you are doing great! I am approaching you in an attempt to initiate a discussion between you and Lg-Websolution. I would be interested in discussing the projects with you . Please let me know a convenient time to Mais

$12 USD / hora
(7 Comentários)
2.8
qiangjin2014

Dear my client I read your description and found that your job is only for me. I'm iOS app developer with rich experience. It is interesting for me and cake-eating. It is my goal to complete your job. Th Mais

$11 USD / hora
(3 Comentários)
1.7
vworkers2214

Hello, I can fix your code and provide working source code. I have around 4 yrs of experience writing iOS apps. Thanks,

$11 USD / hora
(1 Comentário)
0.0
INCtechnology

Hi, We have understand your requirement,we done many apps with these kind requirements. Here are some of our works.  IOS BAsed [url removed, login to view] [url removed, login to view] Mais

$15 USD / hora
(0 Comentários)
0.0
buissonth

Hello, I am a iOSDevelopper for 1 year but i am looking for my first job on [url removed, login to view], I am also working in Airbus about Robotics and Mechatronics. I have good skills in Objective-C. I used to implement the Mais

$8 USD / hora
(0 Comentários)
0.0