Skip to content

Instantly share code, notes, and snippets.

View naveedmcs's full-sized avatar
👨‍💻
Nothing is interesting if You are not interested.

Muhammad Naveed naveedmcs

👨‍💻
Nothing is interesting if You are not interested.
View GitHub Profile
@naveedmcs
naveedmcs / DateFormat.text
Created November 21, 2017 13:18
DateFormat in objective c
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [formatter dateFromString:dateString];
[formatter setDateFormat:@"MM/dd/yyyy"];
NSString *dateOutString = [formatter stringFromDate:date];
invoiceDate_lbl.text = dateOutString;
@naveedmcs
naveedmcs / customFormatDateAndTime.m
Last active December 6, 2017 12:52
Code Snippet For CustomeFormat dateAndTime In Objective C
//Step 1: Declare function in header file
-(NSString*) customFormateDateTime:(NSString*)currentDateTime setCurrentDateTimeFormat:(NSString*)currentFormate SetNewDateTimeFormate:(NSString*)newFormate;
//Step 2: add function definition in .m file
-(NSString*) customFormateDateTime:(NSString*)currentDateTime setCurrentDateTimeFormat:(NSString*)currentFormate SetNewDateTimeFormate:(NSString*)newFormate{
//create object from NSDateFormater
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
@naveedmcs
naveedmcs / labelStyle.m
Created December 14, 2017 12:10
label styling in at RunTime: Objective C
NSString * titleString = [itemLabels objectAtIndex:indexPath.row];
//create attributedstring object with intialize string
NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc]initWithString:titleString];
// formate style
[attriStr setColorForText:titleString withColor:BLUE_COLOR];
[attriStr setFontForText:titleString withFont:[UIFont fontWithName:@"RobotoCondensed-Regular" size:20]];
//redefine width
CGSize maximumSize = CGSizeMake(250, INT_MAX); // CGSizeMake(width,height).
CGRect lblFrame = cell.title_lbl.frame;
lblFrame.size.width = maximumSize.width;
@naveedmcs
naveedmcs / txtFieldvalidation.m
Last active December 28, 2017 12:38
textFieldValidation in objective c
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if (string.length == 0) {
return YES;
}
NSInteger length = textField.text.length+string.length;
if (textField == pharmacyPhone_TF2 || textField == prescriberNumber_TF ) {
if (length < 12) {
[AppInfo toggleViewState:continueBtn isEnabled:[self shouldEnableButton]];
@naveedmcs
naveedmcs / stringformatPattern.m
Created December 15, 2017 11:10
stringPatternFormate in Objective C
- (NSMutableAttributedString *)parseSubjet:(NSString *)subject {
NSMutableAttributedString *attributedSubject = [[NSMutableAttributedString alloc] initWithString:subject];
NSRange rangeSubject = (NSRange){0,[attributedSubject length]};
[attributedSubject addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"RobotoCondensed-Regular" size:16] range:rangeSubject];
if ([subject containsString:@"<<"]) {
NSArray *strings = [subject componentsSeparatedByString:@"<<"];
if (strings.count > 0) {
attributedSubject = [[NSMutableAttributedString alloc] initWithString:@""];
for (int i=0; i<strings.count; i++) {
NSArray *stringComponents = [strings[i] componentsSeparatedByString:@"_"];
@naveedmcs
naveedmcs / GetAgeFromStringTypeDateOfBirth.m
Last active December 20, 2017 10:46
GetAgeFromStringTypeDateOfBirth Objective C
//CREATE OBJECT DATEFORAMTER
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//DECLARE ACTUAL FORMAT OF STRING VALUE
[dateFormat setDateFormat:@"MM/dd/yyyy"];
//CONVERT SRING TO DATE TYPE
NSDate *birthday = [dateFormat dateFromString: @"11/25/1994"];
//GET CURRENT DATE
NSDate* now = [NSDate date];
// PASS PARAMETERS TO AGE COMPONENETS
@naveedmcs
naveedmcs / ColorString AttributedmutableString.m
Last active January 31, 2018 15:17
Color and font formate Method for reusablity
//nvd- Reusable Methods
- (NSMutableAttributedString*)FormateString:(NSString*)actualString forTextRangeColor:(UIColor*)textColor ForTextRange:(NSString*) textRangeString {
NSMutableAttributedString *colorString = [[NSMutableAttributedString alloc]initWithString:actualString];
[colorString setColorForText:textRangeString withColor:textColor];
return colorString;
}
@naveedmcs
naveedmcs / ValidateKeyAndValue.m
Last active January 22, 2018 16:25
Validate Key And value of Data Dictionary -ReUsableMethod Objective C
// Parameters required 1-Value, 2-key and 3- DicitionaryName
- (BOOL)ValidateKeyAndValueString:(NSString*)ValueString forKey:(NSString*)KeyString forDictionary:(NSDictionary*)DictionaryName {
if([AppInfo isValidKey:KeyString forDictionary:DictionaryName]){
if( ValueString == (NSString *)[NSNull null] || ValueString.length == 0 ){
return NO;
}
else{
return YES;
@naveedmcs
naveedmcs / ReadMe.md
Last active January 21, 2018 20:26
ScrollView_reusableCode Objective c

ScrollView programmatically in Objective C

resuable code for adding scroll view in project

Getting Started

  1. create NewController.
  2. in MainView add SubView and rename to ContentView and Create outlit to headerFile
  3. add ScrollView code to View Did load Method
  4. Iphone Size code add in app constant.h file (Bool varibales for global Use)
@naveedmcs
naveedmcs / firebase-push-notifications.text
Created January 19, 2018 17:05
firebase-push-notifications- Artical
https://www.appcoda.com/firebase-push-notifications/