Showing posts with label .PCH File related.... Show all posts
Showing posts with label .PCH File related.... Show all posts

6 May 2017

Updated * Great Tricks to DEBUG with NSLog...DLog Prints Only when Breakpoints(DEBUG) present.ALog Prints Always..ULog Shows a Alert View where it is located with view controller name & method name...


Updated *Great Tricks to DEBUG with NSLog... DLog Prints Only when Breakpoints(DEBUG) presentALog Prints Always.. ULog Shows a Alert View where it is located with view controller name & method name...



**** This will works when in Edit Scheme > Run > info > Build Configuration 1. Debug mode (Default) Prints DLog, ALog & ULog  2. In release mode  Only ALog Prints..

1. Add Below Code in created .PCH File of your Project.  i already said how to create .PCH File in my previous Post.

#define NSLog if(1) NSLog /* Useful for NSLog Prints for 1 & didn't print for 0 */

#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...)
#endif
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#ifdef DEBUG
#   define ULog(fmt, ...)  { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__]  delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
#   define ULog(...)
#endif

2.Now add Logs in your project wherever  you want..

DLog Prints Only when Breakpoints(DEBUG) present.


DLog(@"hdhsk=========================================>?>>>>>>>>");



ALog Prints Always..

ALog(@"ALOG,,dssl;fmklgjkfjgfgvdfgv");

ULog Shows a Alert View where it is located with view controller name & method name..

ULog(@"ULOG----------------------");

How to Add a .Pch file to Xcode 8 to access some classes throughout Application...


How to Add a .Pch file to Xcode 8 to access classes throughout Application...


1. Open your existing Project Xcode.  Right Click in Project navigator(Left panel which has all Classes folder) > New File > iOS > in this Other a file shown with the name PCH File select it > Next.

2. Give the name to PCH File as YourProjectNameHeaderPrefix.pch  then a > PCH File will be created in your Project.

3. Now add the classes like  e.g.

#import "AppProperties.h"
#import "JsonConverter.h"
#import "WebServiceDefines.h"
#import "Utils.h"

in that file.

4. Then go to Project under that go to TARGETS > Build settings > search for Prefix Header > in Precompile Prefix Header Change NO to Yes > in Prefix Header  add $(SRCROOT)/YourProjectNameHeaderPrefix.pch  

5. Finally Once clean the project Now Check > there is No need of importing those classes in your project to access those classes where ever you want without importing them into a class.

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0