Friday, 7 March 2014

Understanding and Analyzing iOS Application Crash Reports (Taken from developer.apple.com

When an application crashes, a "crash report" is created which is very useful for understanding what caused the crash.

This document contains essential information about    how to 

  • symbolicate
  • understand
  • interpret crash reports  

Introduction

When an application crashes on an iOS device, a "crash report" is created and stored on the device. Crash reports describe the conditions under which the application terminated, in most cases including a complete stack trace for each executing thread, and are typically very useful for debugging issues in the application. If you are an iOS developer, you should look at these crash reports to understand what crashes your application is having, and then try to fix them.


Low memory

Low memory reports differ from other crash reports in that there are no stack traces in this type of reports. When a low memory crash happens, you must investigate your memory usage patterns and your responses to low memory warnings. This document points to you several memory management references that you might find useful.



When a low-memory condition is detected, the virtual memory system in iOS relies on the cooperation of applications to release memory. Low-memory notifications are sent to all running applications and processes as a request to free up memory, hoping to reduce the amount of memory in use. If memory pressure still exists, the system may terminate background processes to ease memory pressure. If enough memory can be freed up, your application will continue to run and no crash report will be generated. If not, your application will be terminated by iOS because there isn't enough memory to satisfy the application's demands, and a low memory report will be generated and stored on the device.
The format of a low memory report differs from other crash reports in that there are no stack traces for the application threads. Memory usage of each process is reported in terms of number of memory pages, which as of this writing are 4KB each. You will see "(jettisoned)" next to the name of any process terminated by iOS to free up memory. If you see it next to your application's name, that confirms the application was terminated for using too much memory. Otherwise, the cause of the crash was not memory pressure. Look for a .crash file (described in the next section) for more information.
When you see a low memory crash, rather than be concerned about what part of your code was executing at the time of termination, you should investigate your memory usage patterns and your responses to low memory warnings



Symoblication  ????


Crash reports with stack traces need to be symbolicated before they can be analyzed. Symoblication replaces memory addresses with human-readable function names and line numbers. If you get crash logs off a device through Xcode's Organizer window, then they will be symbolicated for you automatically after a few seconds. Otherwise you will need to symbolicate the.crash file yourself by importing it to the Xcode Organizer. See Symbolication for details.
This document also talks about exception codes, another useful information for identifying the cause of the crash.

The most interesting part of a crash report is the stack trace of your application at the time execution halted. This trace is similar to what you would see when stopping execution in the debugger, except that you are not given the method or function names, known as symbols. Instead, you have hexadecimal addresses and executable code - your application or system frameworks - to which they refer. You need to map these addresses to symbols. The logs do not contain symbol information when they're written out. You have to symbolicate the logs before you can analyze them.
Symbolication - resolving stack trace addresses to source code methods and lines - requires the 
application binary that was uploaded to the App Store and the .dSYM file that was generated when that
 binary was built. This must be an exact match - otherwise, the report cannot be fully symbolicated. It 
is essential that you keep each build distributed to users (regardless of the details of that distribution)
 with its .dSYM file.




Xcode's "Archive" command makes it easy keeping the matching binary and the .dSYM. When you use the "Archive" command (by choosing "Archive" from the "Product" menu or by pressing Shift+Command+B), Xcode will gather the application binary and the .dSYM containing symbol information together and store them in a location in your home folder. You can find all of your archived applications in the Xcode Organizer under the "Archived" section. Xcode will automatically search archived applications when symbolicating crash reports, and you can submit archived applications directly to iTunes Connect ensuring that the application and .dSYM that you have archived match what you release.
Xcode will automatically symbolicate all crash reports that it encounters, if it has the .dSYM and application binary that produced the crash report. Given a crash report, the matching binary, and its .dSYM file, all you need to do for symbolication is to add the crash report to the Xcode Organizer. Open the Xcode Organizer, select the “Devices” tab, select “Device Logs” under “LIBRARY” on the top of the sidebar, click the "Import" button and select the .crash file. When it's done, Xcode will automatically symbolicate the crash report and display the results.




Exception codes

In the crash log is a line that starts with the text Exception Codes: followed by one or more hexadecimal values. These are processor-specific codes that may give you more information on the nature of the crash.
  • The exception code 0xbaaaaaad indicates that the log is a stackshot of the entire system, not a crash report. To take a stackshot, push the home button and any volume button. Often these logs are accidentally created by users, and do not indicate an error.
  • The exception code 0xbad22222 indicates that a VoIP application has been terminated by iOS because it resumed too frequently.
  • The exception code 0x8badf00d indicates that an application has been terminated by iOS because a watchdog timeout occurred. The application took too long to launch, terminate, or respond to system events. One common cause of this is doing synchronous networking on the main thread. Whatever operation is on Thread 0: needs to be moved to a background thread, or processed differently, so that it does not block the main thread.
  • The exception code 0xc00010ff indicates the app was killed by the operating system in response to a thermal event. This may be due to an issue with the particular device that this crash occurred on, or the environment it was operated in. For tips on making your app run more efficiently, see iOS Performance and Power Optimization with Instruments WWDC session.
  • The exception code 0xdead10cc indicates that an application has been terminated by iOS because it held on to a system resource (like the address book database) while running in the background.
  • The exception code 0xdeadfa11 indicated that an application has been force quit by the user. Force quits occur when the user first holds down the On/Off button until "slide to power off" appears, then holds down the Home button. It's reasonable to assume that the user has done this because the application has become unresponsive, but it's not guaranteed - force quit will work on any application.

Wednesday, 29 January 2014

TTCounterLabel for iOS



A custom UILabel that acts as a time counter, counting up or down and formatting the string to hours, minutes, seconds and milliseconds. Designed to accept a value in milliseconds that is then displayed it in a time friendly format. Currently the controls supports up-to a maximum value of 99 hours 59 minutes 59 seconds and 999 milliseconds, which should be enough for most uses. The control automatically removes any leading zeros and centralises the result. It also supports different fonts for each unit division.


TTCounterLabel

A custom UILabel that acts as a time counter, counting up or down and formatting the string to hours, minutes, seconds and milliseconds. Designed to accept a value in milliseconds that is then displayed it in a time friendly format. Currently the controls supports up-to a maximum value of 99 hours 59 minutes 59 seconds and 999 milliseconds, which should be enough for most uses. The control automatically removes any leading zeros and centralises the result. It also supports different fonts for each unit division.
Alt text

Setup

Installing with CocoaPods
If you're unfamiliar with CocoaPods there is a great tutorial here to get you up to speed.
  1. In Terminal navigate to the root of your project.
  2. Run 'touch Podfile' to create the Podfile.
  3. Open the Podfile using 'open -e Podfile'
  4. Add the pod TTCounterLabel to your Podfile.
    platform :ios
    pod 'TTCounterLabel'
    
  5. Run pod install.
  6. Open your app's .xcworkspace file to launch Xcode and start using the control!
Installing manually from GitHub
  1. Download the TTCounterLabel.h and TTcounterLabel.m files and add them to your Xcode project.
  2. #import TTCounterLabel.h wherever you need it.
  3. Follow the included sample project to get started.
Running the sample project
Check out the sample project included in the repository. Just open the '.xcworkspace' file in the Sample folder and the project should build correctly.

Author(s)

Licence

Distributed under the MIT License.



Download source code from here

CircularTimer


CircularTimer

CircularTimer is a class that creates a custom circular timer, showing the percentage completed between two dates.

Installation

Drop the files CircularTimer.h and CircularTimer.m into your Xcode project.

Usage

In your ViewController import the header file CircularTimer.h, and create a CircularTimer property to keep a reference:
@property (nonatomic, strong) CircularTimer *circularTimer;
Then, to create the object use a code like this:
self.circularTimer = 
[[CircularTimer alloc] initWithPosition:CGPointMake(0.0f, 0.0f)
                                 radius:radius
                         internalRadius:internalRadius
                      circleStrokeColor:circleStrokeColor
                activeCircleStrokeColor:activeCircleStrokeColor
                            initialDate:initialDate
                              finalDate:finalDate
                          startCallback:^{
                              //do something
                          }
                            endCallback:^{
                                //do something
                            }];
and add it as subview
[self.view addSubview:self.circularTimer];

Methods

Create a CircularTimer using:
- (id)initWithPosition:(CGPoint)position
                radius:(float)radius
        internalRadius:(float)internalRadius
     circleStrokeColor:(UIColor *)circleStrokeColor
activeCircleStrokeColor:(UIColor *)activeCircleStrokeColor
           initialDate:(NSDate *)initialDate
             finalDate:(NSDate *)finalDate
         startCallback:(void (^)(void))startBlock
           endCallback:(void (^)(void))endBlock;       
You can see the meaning of radiusinternalRadiuscircleStrokeColor and activeCircleStrokeColorin this image:
image
- (BOOL)isRunning;
Indicates if the CircularTimer is currently running.
- (BOOL)willRun;
Indicates if the CircularTimer will run (in other words, if the current time is smaller than the CircularTimerfinalDate).
- (void)stop;
Stops the CircularTimer.
- (NSTimeInterval)intervalLength;
Returns the interval between the initialDate and the finalDate.
- (NSTimeInterval)runningElapsedTime;
Returns the interval of time elapsed since the CircularTimer started running.

Demo

You can find a demo project in this repository. Meanwhile, you can watch a teaser:

About us

CROWD STUDIO

Licence

Copyright (C) 2013 CROWD STUDIO
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download Source Code from here

Saturday, 25 January 2014

Download Images Asynchronously



Hi this is a simple code that used to download images from url in background.

  
    
    dispatch_queue_t imageLoadQueue = dispatch_queue_create("com.gmm.test",NULL);
    
    dispatch_async(imageLoadQueue, ^{
//Wait for 5 seconds...
        usleep(1000000);
        docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        
        
        for(int k=0; k <[allImage count] ;k++){
            
           
            imgURL = [allImage objectAtIndex:k];
            [imagePreview addObject:imgURL];
            imgData=[NSData dataWithContentsOfURL:[NSURL URLWithString:imgURL]];
           
            
            [imgData writeToFile:[NSString stringWithFormat:@"%@/%@", docPath, [imgURL lastPathComponent]] atomically:YES];
            
            
        }
//reload ur viewcontroller or tableview or collectionview  if necessary           
        
     
    });

    

Adding Google Analytics to your iOS App

Hi..Anyone heard about google analytics??? hope most of you guys know about it.

http://www.google.co.in/analytics/

Your customers go everywhere; shouldn't your analytics? Google Analytics shows you the full customer picture across ads and videos, websites and social tools, tablets and smartphones. That makes it easier to serve your current customers and win new ones.


Know your audience

No two people think exactly alike. Google Analytics helps you analyze visitor traffic and paint a complete picture of your audience and their needs, wherever they are along the path to purchase.


Trace the customer path

Where customers are can be as critical as who they are. Tools like Traffic Sources and Visitor Flow help you track the routes people take to reach you, and the devices they use to get there, so you can meet them where they are and improve the visitor experience.

See what they're up to

Do some types of people give you better results? You'll find out with tools like In-Page Analytics, which lets you make a visual assessment of how visitors interact with your pages. Learn what they're looking for and what they like, then tailor all your marketing activities — from your site to your apps to your ad campaigns — for maximum impact.



How to setup a Google Analytics account??

Please follow the link


to know more about Analytics account please check this video