Common iOS memory mistakes developers commit

Leave a comment


Some of the common mistakes an iOS developer does are provided below:

1. Missing dealloc method as part of  each Class

2. Missing [super dealloc] methods call in dealloc method.

3. Leaving NSLog statements in production ready code. Too much NSLog can consume lot of memory and your app will throw memory warning very soon.

4. Not being aware of the power of iOS debugger commands to nail the crashes. Environment variables NSZombieEnabled, NSDebugEnabled, MallocStackLogging can help you a lot in finding the reasons behind crashes.

5. When using the above commands, forgetting to disabled in the production code.

6. Not leveraging the power of accessors. To leverage their power read this document https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html

7. Not setting pointers to nil after releasing. Even though this is not necessary,  doing this is will help us in avoiding any inadvertant usage of this object variable, unless it is reassigned with any other object.

8. Trying to use retainCount of objects created.  Since there is no  1 to 1 correspondence between the retain count and calls to  retain/release, it is better we refrain from sing this.  This link might be use ful .http://www.friday.com/bbum/2011/12/18/retaincount-is-useless/

This list will be a living list and I will keep updating it.

duplicate symbol _OBJC_CLASS_$_SBJSON

1 Comment


I used Selenium NativeDriver for Testing an App. My Application was using JSON Library.  And I was getting the below  error on building:

duplicate symbol _OBJC_CLASS_$_SBJSON.

I learned that The NativeDriver library was using JSON for data transfer. So It also was using the same  JSON library.

I was able to fix the problem by excluding the JSON Source files through Xcode settings.

The fix is as below:

Add a user-defined build setting with the name “EXCLUDED_SOURCE_FILE_NAMES”  in Build Settings for the Project’s Target ,  and for the value add :

JSON.h SBJSON.h SBJSON.m SBJsonBase.h SBJsonBase.m SBJsonParser.h SBJsonParser.m SBJsonWriter.h SBJsonWriter.m NSObject+SBJSON.h NSObject+SBJSON.m NSString+SBJSON.h NSString+SBJSON.m

Below images might help you in adding  User defined setting to Project.

Preapproval Process using PayPal MPL in Android

1 Comment


Introduction

The objective of the document is to explain the steps involved in doing auto renewal payment in PayPal using its Mobile Payment library for android mobile.

Steps to get confirmed PreApproval Key

  1. The first step towards integrating PayPal with android application is that we need a PayPal sandbox account for testing. So create new sandbox account if you don’t have one from following URL https://developer.paypal.com/cgi-bin/devscr?cmd=_signup-run
  2. Sign in with the user id and password.
  3. Create Test accounts for both buyer and seller. You will get the API credential while creating seller account, those API credential will be used for getting preapproval key and payments.
  4. From your Local server send the preapproval request to paypal using the following parameters. You should use your account details and API credentials here.
    1. requestUrl: https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval
    2. requestMethod: POST
    3. requestBody: requestEnvelope.errorLanguage=en_US&cancelUrl=http://www.bytelyte.com/PayPal_X_NVP_tester.php?cmd=test&currencyCode=USD&endingDate=2011-11-11&maxAmountPerPayment=30&maxNumberOfPayments=4&maxTotalAmountOfAllPayments=120&pinType=NOT_REQUIRED&returnUrl=http://www.bytelyte.com/PayPal_X_NVP_tester.php?cmd=test&startingDate=2011-09-21&senderEmail=your buyer mail id
    4. headers: charset”,”utf-8″,”Content-Type”,”text/xml”,”X-PAYPAL-DEVICE-IPADDRESS”,”127.0.0.1″,”X-PAYPAL-APPLICATION-ID”,”APP-80W284485P519543T”,”X-PAYPAL-RESPONSE-DATA-FORMAT”,”JSON”,”X-PAYPAL-REQUEST-DATA-FORMAT”,”NV”,”X-PAYPAL-SECURITY-SIGNATURE”,”API Signature”,”X-PAYPAL-SECURITY-PASSWORD”,” API password “,”X-PAYPAL-SECURITY-USERID”,”API UserName”
  5. If the above process and parameters are correct you will get a Preapproval key from server as response.
  6. Response:{“responseEnvelope”:{“timestamp”:”2011-09-21T02:54:44.020-07:00″,”ack”:”Success”,”correlationId”:”606efc1b8abb0″,”build”:”2142261″},”preapprovalKey”:”PA-81Y46219NL419022F”}
  7. This Preapproval Key say PA-81Y46219NL419022F has to authorize by the application. Pass the Preapproval key and merchant name to PayPal MPL from your android application. Here we used “SimpleDemo” android application given by the PayPal MPL library for understanding purpose.
  8. The Mobile User should login and agree the PayPal preapproval payment. After the user agreement the preapproval key get authorized and return back to the application.

Steps to make Payment

From your Local server by using the authorized preapproval key you can make a payment using the following parameters.

  1. requestUrl: https://svcs.sandbox.paypal.com/AdaptivePayments/Pay
  2. requestMethod: POST
  3. requestBody: requestEnvelope.errorLanguage=en_US&actionType=PAY&preapprovalKey= Authorized preapproval key&receiverList.receiver(0).amount=30.00&receiverList.receiver(0).email=your seller mail id¤cyCode=USD&feesPayer=EACHRECEIVER&memo=Simple payment example.&cancelUrl=http://your_cancel_url&returnUrl=http://your_return_url&ipnNotificationUrl=http://your_ipn_notification_url
  4. headers : “charset”,”utf-8″,”Content-Type”,”text/xml”,”X-PAYPAL-DEVICE-IPADDRESS”,”127.0.0.1″,”X-PAYPAL-APPLICATION-ID”,”APP-80W284485P519543T”,”X-PAYPAL-RESPONSE-DATA-FORMAT”,”JSON”,”X-PAYPAL-REQUEST-DATA-FORMAT”,”NV”,”X-PAYPAL-SECURITY-SIGNATURE”,”API Signature”,”X-PAYPAL-SECURITY-PASSWORD”,” API password “,”X-PAYPAL-SECURITY-USERID”,”API UserName”

If the above parameters are correct the amount mentioned in the “receiver(0).amount=” column will get transferred to the seller account and you will get a Pay Key as response from the PayPal server. You can login in to both seller and buyer account to ensure the above process.

putpkt: write failed, broken pipe

Leave a comment


When you get this error while testing an App in iOS device, with out further ado you can do the following to get out of it:

1. Reboot your device

2. Clean your build and rebuild the project and launch the App.

If you get the same problem again add the following options to your procedure:

1. Delete the App from the device

2. Restart XCode.

At times you can get rid of this problem only by Factory Rest of your device.

java.sql.SQLException: The Network Adapter could not establish the connection

Leave a comment


For one of the Web services we were developing we used Oracle DB as the source. We kept getting the error “java.sql.SQLException: The Network Adapter could not establish the connection”. After checking the network adapter, the DB server , there was no use at all. Everything was working well. I thought if I can check the validity of the URL formed. On checking it I found the problem. The URL I formed was having unnecessarily  \es between URL part. I was using \ between and port and oracle-sid.

The format of the URL should be as follows:

jdbc:oracle:thin:@hostname:port:oracle-sid

Another format to use along with  credentials is:(I have not tested this in the App)

jdbc:oracle:thin:username/password@hostname:port:oracle-sid

 

Thanks to jguru:

http://www.jguru.com/faq/view.jsp?EID=444466

 

Ability to detect change in wi-fi change in iOS

Leave a comment


I was just exploring if we can find when our iPhone or iPad changes from one wi-fi to another. I felt we can detect this based on the SSID of the access point. And there is a framework named MobileApple80211. But since this library internally uses the private APIs of iOS, we can not use this to detect the change in wi-fi network. If you know any other ways to do it, please share it.

 

 

5 Things CIOs need to know before mobile-enabling

Leave a comment


Webinar at Aspire Systems

Webinar at Aspire Systems

Join us for a Webinar                                                                         
Theme: 5 things CIOs need to know before mobile-enabling
Date: Thursday, June 2, 2011
Time: 11 AM PST / 2 PM EST

“More than 4 billion people around the world now use cell phones, and for 450 million of those people, the Web is a fully mobile experience,” according to the McKinsey Global Institute. This explosive growth of mobile is having a significant impact on B2C and B2B businesses.

Mobile-enablement, however, is more than just tailoring your website’s content to fit a smaller screen. There are several options and challenges involved in going the mobile route. Executives overseeing mobile initiatives need to be aware of the considerations – in order to get the maximum RoI from their mobile strategy.

Come listen to two experienced practitioners discuss key elements that will be crucial in your mobile strategy, on June 2nd, 2011 at 2 PM EST.

Some areas that will be covered include:

Native mobile apps Vs. Mobile web

Design simplicity: where less is more

Mobile as a new channel for growth

And much more…

Speaker Profiles

William Walsh
Senior Manager – Mobile strategy
Discover Financial Services

William is a pioneer and thought-leader in the wireless industry. He has created and driven development of mobile multimedia applications (now used on 100+ million devices worldwide) including entry into the emerging $13 billion mobile advertising market and $35 billion location based services market.

In his previous role as Mobile Product Manager at Walgreens, he successfully launched Walgreens iPhone, Android, and Blackberry applications. He defined the marketing message for Walgreen’s iPhone application and propelled it to No.3 in the iTunes Lifestyle category – the app also won in 2 categories of the Webby awards.

Vinod K
Mobile Practice Manager
Aspire Systems

Vinod is an IT practitioner for the last 13 years, with over 10 years working in the mobile space. Vinod understands what it takes to go mobile – the challenges, pros and cons of different approaches. He has consulted several Fortune 500 companies and helped them define their mobile roadmap.

Vinod has hands-on experience working on various mobile technologies, right from programming for Palm OS close to 10 years ago, to leading a 20+ member team for a Fortune 500 company in the retail space recently. Vinod led the team working on their iPhone and Android apps (the iphone was subsequently one of the top 5 apps in the iTunes Lifestyle category).

Older Entries Newer Entries