In-App purchases not working on iPhone? - iphone

This is the code:
-(IBAction)purchase5010:(id)sender{
productUserRequests = 0;
SKPayment *payment = [SKPayment paymentWithProductIdentifier:#"com.mobice.wtm.5010"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:productUserRequests];
}else if(!validProduct){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"No products available at this time."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:productUserRequests];
}else if(!validProduct){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"No products available at this time."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
if (productUserRequests == 0) {
NSString *hints = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Hints"]];
int hintValue = [hints intValue];
hintValue+=50;
[hints release];
hints = [[NSString alloc]initWithFormat:#"%i", hintValue];
[hints writeToFile:[self pathOfFile:#"Hints"] atomically:YES];
NSString *reveals = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Reveals"]];
int revealValue = [reveals intValue];
revealValue+=50;
[reveals release];
reveals = [[NSString alloc]initWithFormat:#"%i", revealValue];
[reveals writeToFile:[self pathOfFile:#"Reveals"] atomically:YES];
}else if(productUserRequests == 1){
NSString *hints = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Hints"]];
int hintValue = [hints intValue];
hintValue+=150;
[hints release];
hints = [[NSString alloc]initWithFormat:#"%i", hintValue];
[hints writeToFile:[self pathOfFile:#"Hints"] atomically:YES];
NSString *reveals = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:#"Reveals"]];
int revealValue = [reveals intValue];
revealValue+=20;
[reveals release];
reveals = [[NSString alloc]initWithFormat:#"%i", revealValue];
[reveals writeToFile:[self pathOfFile:#"Reveals"] atomically:YES];
}
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"In-app purchase failed. No money was charged."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
}
}
Now, whenever I attempt to purchase the item, it says "No products available at this time.", and also "In-app purchase failed. No money was charged."
I want to know, is there something wrong with the code above? Or is it more likely an itunes connect issue?

Instead of the full bundle id for the request: #"com.mobice.wtm.5010", go ahead and feed it just a #"5010".
For example I have a product com.example.somerandomapp.track01 the following code works:
SKPayment *paymentRequest = [SKPayment paymentWithProductIdentifier: #"track01"];
There are alot of different factors that can lead to the error, this is a good list of what can lead to failure here

Related

Want to get my captured video back

I have created a camera using AVFoundation, now i want my video back so i can upload it on my server how can i do that ?
I am using MKNetworkKit for upload video on server.
I am getting output like this:
file://localhost/private/var/mobile/Applications/4B2E02E5-3EE2-493E-8ECF-4B1DA29B9387/tmp/output.mov
Guys I have figured out it by some help here is code for that.
- (void) captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)anOutputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{
videodata = [NSData dataWithContentsOfURL:outputFileURL];
//NSLog(#"output file url is :%#",anOutputFileURL);
NSLog(#"output video data size is:%d", videodata.length);
if ([[self delegate] respondsToSelector:#selector(recorder:recordingDidFinishToOutputFileURL:error:)]) {
[[self delegate] recorder:self recordingDidFinishToOutputFileURL:anOutputFileURL error:error];
}
//NSLog(#"captureOutput is: %#",captureOutput);
// NSLog(#"anOutputFileURL is: %#",anOutputFileURL);
//videoPath = [NSString stringWithContentsOfURL:anOutputFileURL encoding:NSUTF8StringEncoding error:nil];
//videoPath = [anOutputFileURL absoluteString];
//videoURL = anOutputFileURL;
// videodata = captureOutput;
// NSLog(#"video path is: %#",videodata);
UIAlertView *message = [[UIAlertView alloc] initWithTitle:nil
message:#"Do you want to upload this content to the yes stream network ?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Yes",#"No",nil];
[message show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Yes"])
{
NSLog(#"Yes was selected.");
self.flUploadEngine = [[fileUploadEngine alloc] initWithHostName:#"manektech.net" customHeaderFields:nil];
NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"testApp", #"appID",
nil];
self.flOperation = [self.flUploadEngine postDataToServer:postParams path:#"/dilipvideotest/savefile.php"];
[self.flOperation addData:videodata forKey:#"uploadfile" mimeType:#"video/mov" fileName:#"output.mov" ];
[self.flOperation onCompletion:^(MKNetworkOperation *operation) {
NSLog(#"response string is : %#", [operation responseString]);
/*
This is where you handle a successful 200 response
*/
}
onError:^(NSError *error) {
NSLog(#"error : %#", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[alert show];
}];
[self.flUploadEngine enqueueOperation:self.flOperation ];
}
else if([title isEqualToString:#"No"])
{
NSLog(#"No was selected.");
//[self readMovie:outputFileURL];
}
}

method called more times

Pretty long question but easy to understand so please take a minute :)
A few weeks ago I created a shop page for my app. I was new to the in-app purchases and got some code of the net. This was made for 1 object so I decided to edit the code to my own needs. one purchase for the pro version of the app and 3 purchases for 3 different amount of coins.
When I buy coins it works fine the only problem is that the second time I buy it will add 2x the amount of coins I bought, the third time it will add 3x the amount of coins I bought etc. I hope someone can take a look at my code and tell me whats wrong. For this topic I've made the code a little smaller and will not show all purchases.
//the 100 coins button
-(IBAction)savedata100:(id)sender {
askToPurchase100Munten = [[UIAlertView alloc]
initWithTitle:#"100 Munten"
message:#"Ga verder om 100 Munten te kopen."
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Verder", #"Cancel", nil];
askToPurchase100Munten.delegate = self;
[askToPurchase100Munten show];
[askToPurchase100Munten release];
//the next step
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
else if (alertView==askToPurchase100Munten) {
if (buttonIndex==0) {
// user tapped YES, but we need to check if IAP is enabled or not.
if ([SKPaymentQueue canMakePayments]) {
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:#"100Munten"]];
Temp = 2;
request.delegate = self;
[request start];
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:#"Prohibited"
message:#"Parental Control is enabled, cannot make a purchase!"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Ok", nil];
[tmp show];
[tmp release];
}
}
}
//the next step
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response
{
statusLabel.text = #"";
int count = [response.products count];
}
if (Temp == 2){
if (count>0) {
SKProduct *selectedProduct = [response.products objectAtIndex:0];
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:#"Not Available"
message:#"No products to purchase"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Ok", nil];
[tmp show];
[tmp release];
}
}
//the last step this is what is being called more and more times every time I do it (the uiView also pops up more times)
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
// show wait view here
statusLabel.text = #"Verwerken...";
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// remove wait view and unlock feature 2
statusLabel.text = #"Klaar!";
if (Temp == 2){
//ADD COINS WHEN PURCHASES IS COMPLETE
int coinsToAdd = 100;
int currentCoins = [[NSUserDefaults standardUserDefaults] integerForKey:#"savedstring"];
int savestring =
currentCoins + coinsToAdd;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:savestring forKey:#"savedstring"]; [defaults synchronize];
[label111 setText:[NSString stringWithFormat:#"Munten: %i",[self getCoins]]];
//ALERTVIEW TO SHOW YOU PURCHASED COINS
UIAlertView *tmp2 = [[UIAlertView alloc]
initWithTitle:#"Voltooid"
message:#"Je hebt 100 Munten Gekocht"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Ok", nil];
[tmp2 show];
[tmp2 release];
Thanks for reading hope someone can help me out :)
Once you made a transaction you should set transaction.transactionState to SKPaymentTransactionStatePurchased, otherwise you will repeat the transaction the next time.

in app purchase implemention

In My app I have to implement in app purchse in below scenerio:-
App is free for all user i.e every person can download it at free of cost.
I have implemented Consumable type for this.
in application there is a option to purchase 10 coins in $1.99.once user purchase it complete transaction successfully
but when again user click on purchased to 10 coins it prompted that "You have already downloaded this app".
I want to implement in app purchase in that wat so that user can purchase 10 coin s multiple type?
What will be type and scenario for this .
Please suggest?
- (void)requestProductData {
// NSLog(#"%#",strCheck);
if ([strCheck isEqualToString:#"inApp"]) {
myString = strCheck;
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:#"All_labelling"]];
request.delegate = self;
[request start];
}
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSArray *myProduct = response.products;
SKPayment *payment = [SKPayment paymentWithProduct:[myProduct objectAtIndex:0]];
[[SKPaymentQueue defaultQueue] addPayment:payment];
[request autorelease];
}
- (void)inAppPurchase {
reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus == NotReachable) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"LeaderFollow!" message:#"Network is not found" delegate:nil cancelButtonTitle:nil otherButtonTitles:#"Ok", nil];
[alert show];
[progInd stopAnimating];
[progInd setHidden:YES];
}
else if ([SKPaymentQueue canMakePayments]) {
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[self requestProductData];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Please enable the ability to make purchases." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
- (void)finishMyTransaction:(SKPaymentTransaction *)transaction {
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
self.view.userInteractionEnabled=YES;
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
[progInd stopAnimating];
[progInd setHidden:YES];
}
#pragma mark Payment Delegate
#pragma mark -
- (void)recordTransaction:(SKPaymentTransaction *)transaction {
}
- (void)provideContent:(NSString *)productIdentifier {
if([productIdentifier isEqualToString:#"All_labelling"]){
strCheck=#"inApp";
myString=strCheck;
}
if ([strCheck isEqualToString:#"inApp"]){
[prefs setBool:YES forKey:#"inApp"];
if(!isTapped){
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"Congratulations!" message:#"You Have Successfully Purchased All Objects Pack" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
[self viewWillAppear:YES];
}
//}
[progInd stopAnimating];
[progInd setHidden:YES];
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction {
[self recordTransaction:transaction];
[self provideContent:transaction.payment.productIdentifier];
[self finishMyTransaction:transaction];
}
-(IBAction)btnRestoreTapped{
[progInd setHidden:NO];
[progInd startAnimating];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
[[UIApplication sharedApplication]beginIgnoringInteractionEvents];
}
- (void)restoreTransaction: (SKPaymentTransaction *)transaction {
[self recordTransaction:transaction];
[self provideContent:transaction.originalTransaction.payment.productIdentifier];
[self finishMyTransaction:transaction];
}
- (void)failedTransaction: (SKPaymentTransaction *)transaction {
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:[transaction.error localizedDescription]
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
[self finishMyTransaction:transaction];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
break;
default:
break;
}
}
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue{
[progInd stopAnimating];
[progInd setHidden:YES];
[[UIApplication sharedApplication]endIgnoringInteractionEvents];
if([prefs boolForKey:#"inApp"]){
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"LeaderFollow!" message:#"You Have Successfully Restored Pack(s)" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
[prefs setObject:#"YES" forKey:#"Restore"];
}
else{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"LeaderFollow!" message:#"No purchases to restore" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
isTapped=NO;
}
- (void)paymentQueue:(SKPaymentQueue*)queue restoreCompletedTransactionsFailedWithError:(NSError*)error
{
[[UIApplication sharedApplication]endIgnoringInteractionEvents];
[progInd stopAnimating];
isTapped=NO;
self.view.userInteractionEnabled=YES;
[progInd setHidden:YES];
}

Implementing in app purchase and its restoration in iphone

I have implemented in app purchase in one of my application using MKStoreManager.Now got a new guideline from apple that if you are doing in app purchase,you have to give the user,the option for restoring the already purchased application.So i have done like this.On the 'restore' button click,this method is called.
- (void) checkPurchasedItems
{
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
and from here,this method is fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
NSMutableArray* purchasableObjects = [[NSMutableArray alloc] init];
NSLog(#"received restored transactions: %i", queue.transactions.count);
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSString *productID = transaction.payment.productIdentifier;
[purchasableObjects addObject:productID];
}
}
But now i have a doubt that how can i check this restoration is working or not.Can anyone guide me.thanks in advance.
Here is how you implement the Restoration
- (void)loadStore
{
// restarts any purchases if they were interrupted last time the app was open
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
// get the product description (defined in early sections)
[self requestProUpgradeProductData];
}
- (void)requestProUpgradeProductData
{
NSSet *productIdentifiers = [NSSet setWithObject:kInAppPurchaseProUpgradeProductId];
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
// we will release the request object in the delegate callback
}
After this it will call this method
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *products = response.products;
proUpgradeProduct = [products count] == 1 ? [[products objectAtIndex:0] retain] : nil;
if (proUpgradeProduct)
{
NSLog(#"Product title: %#" , proUpgradeProduct.localizedTitle);
NSLog(#"Product description: %#" , proUpgradeProduct.localizedDescription);
NSLog(#"Product price: %#" , proUpgradeProduct.price);
NSLog(#"Product id: %#" , proUpgradeProduct.productIdentifier);
if ([self canMakePurchases]) {
if ([self respondsToSelector:#selector(purchaseProUpgrade)]) {
[self purchaseProUpgrade];
}
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[self languageSelectedStringForKey:#"Error"] message:#"Cannot connect to Store.\n Please Enable the Buying in settings" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
}
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
[SVProgressHUD dismiss];
[cancelButton setEnabled:YES];
[buyNowButton setEnabled:YES];
[restoreButton setEnabled:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Warning" message:#"Error occured" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
NSLog(#"Invalid product id: %#" , invalidProductId);
}
// finally release the reqest we alloc/init’ed in requestProUpgradeProductData
[productsRequest release];
[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
[self recordTransaction:transaction];
[self provideContent:transaction.payment.productIdentifier];
[self finishTransaction:transaction wasSuccessful:YES];
}
- (void)purchaseProUpgrade
{
[SVProgressHUD showInView:self.view status:[self languageSelectedStringForKey:#"Connecting Store"] networkIndicator:YES];
SKPayment *payment = [SKPayment paymentWithProductIdentifier:kInAppPurchaseProUpgradeProductId];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
if ([transaction.payment.productIdentifier isEqualToString:kInAppPurchaseProUpgradeProductId])
{
// save the transaction receipt to disk
[[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt forKey:#"proUpgradeTransactionReceipt" ];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
Finally this method
- (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful: (BOOL)wasSuccessful
{
// remove the transaction from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:transaction, #"transaction" , nil];
if (wasSuccessful)
{
//Write your transaction complete statement required for your project
}

regarding potential leak

am getting the potential leak in the following code.(returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];)pls help me to find out.
+ (NSString *) getResponseFromServer:(NSString *) url
{
NSString *URLString1 = [NSString stringWithContentsOfURL:[NSURL URLWithString:#"http://www.google.com"]];
if(URLString1 == NULL)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Info" message:#"You must be connected to the Internet to use this app. Wireless , 3G and EDGE are supported" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
alert.delegate = self;
[alert show];
[alert release];
return #"NO" ;
}
else
{
//CFStringRef escapeChars = (CFStringRef) #":/?#[]#!$&’()*+,;=";
// url = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)url, NULL, escapeChars, kCFStringEncodingUTF8);
url = [url stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
//[self alert:escapedUrlString];
url=[url stringByReplacingOccurrencesOfString:#"%2526" withString:#"%26"];
//NSLog(#"url 2 = %# ",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:url]];
NSLog(#"******Loading URL = %#",[NSURL URLWithString:url]);
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = #"";
if(returnData)
{
returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; //Potential leak here...
// NSRange range = [str rangeOfString:supplierSearchText.text options:NSCaseInsensitiveSearch];
//NSLog(#"Searching = %d, %#, %#, %d", i, str, supplierSearchText.text, range.location);
//if(range.location == 0)
int num = [url rangeOfString:#"iphone_logout.php" options:NSCaseInsensitiveSearch].location;
NSLog(#">>>>>>>>> NUmber = %d", num);
if(isUserLoggedIn > 0 && global_Timer != nil && num > 1000)
{
if(((int)([url rangeOfString:#"iphone_user.php" options:NSCaseInsensitiveSearch].location) < 1000) ||
((int)([url rangeOfString:#"company_name.php" options:NSCaseInsensitiveSearch].location) < 1000) ||
((int)([url rangeOfString:#"company_search.php" options:NSCaseInsensitiveSearch].location) < 1000) ||
((int)([url rangeOfString:#"view_web.php" options:NSCaseInsensitiveSearch].location) < 1000))
{
[global_Timer invalidate];
NSLog(#">>>>>>>> Timer invalidating >>>>>>>>>>>>>>, %d, %d, %d, %d", ((int)([url rangeOfString:#"iphone_user.php" options:NSCaseInsensitiveSearch].location) > -1) , ((int)([url rangeOfString:#"company_name.php" options:NSCaseInsensitiveSearch].location) > -1) , ((int)([url rangeOfString:#"company_search.php" options:NSCaseInsensitiveSearch].location) > -1), ((int)([url rangeOfString:#"view_web.php" options:NSCaseInsensitiveSearch].location) > -1) );
global_Timer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)300.0 target:global_SupplierToolsViewController selector:#selector(pressButton_Logout) userInfo:nil repeats:NO];
}
else {
NSLog(#"No matches found!, %d", (int)([url rangeOfString:#"iphone_user.php" options:NSCaseInsensitiveSearch].location));
}
}
}
else //if(!networkFlag)
{
//networkFlag = YES;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Network connection failed! Try again later!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return #"NO";
}
//[url release];
[request release];
return returnString;
}
}
You could add autorelease to the creation of the string.
In general, any time you use alloc you need to either use autorelease or else use release.
You have a path that returns before releasing the request.
else //if(!networkFlag)
{
//networkFlag = YES;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Network connection failed! Try again later!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return #"NO";
}
//[url release];
[request release];
You are alloc-ing returnString without a matching release.
Try having an autoreleased string, like so:
returnString = [NSString stringWithData:returnData encoding:NSUTF8StringEncoding];