Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Nikola Kirev NikolaKirev

🎯
Focusing
Block or report user

Report or block NikolaKirev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NikolaKirev
NikolaKirev / HashtagFiltering.m
Last active Dec 28, 2015
Find hashtag words in an NSString using NSPredicate
View HashtagFiltering.m
//A code snippet, that can be used to search for hashtags in a given NSString
//Instantiate a mutable array containing all the words. We sepparate the original string into words.
NSMutableArray *hashtagWordsArray = [NSMutableArray arrayWithArray:[<An NSString> componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
NSPredicate *hashtagDetectionPredicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH %@", @"#"];
[hashtagWordsArray filterUsingPredicate:hashtagDetectionPredicate];
//Log the result
NSLog(@"Hashtags: %@", hashtagWordsArray);
View ios5direcyions.m
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
currentLocation.coordinate.latitude,
currentLocation.coordinate.longitude,
[destionationObject.latitude doubleValue],
[destionationObject.longitude doubleValue]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
View activity.m
- (IBAction)sharePressed:(id)sender {
if (NSClassFromString(@"UIActivityViewController")) {
NSURL *urlStringToShare = _webView.request.URL;
NSArray *dataToShare = @[urlStringToShare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:dataToShare
applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
}
}
@NikolaKirev
NikolaKirev / weekday.m
Created Apr 12, 2013
Using Localised Weekday Name Strings
View weekday.m
- (NSString *)localizedWeekdayStringForDate:(NSDate *)date {
// We first get the index of the weekday from NSDateComponents
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSWeekdayCalendarUnit fromDate:date];
// The weekdays start from Sunday and from index 1
// 1 - Sunday, 2 - Monday ...
int weekdayNumber = [components weekday];
// We need an NSDateFormatter to have access to the localized weekday strings
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
@NikolaKirev
NikolaKirev / mapDirections.m
Last active Dec 16, 2015
Map Directions tutorial
View mapDirections.m
Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
MKMapItem *currentLocationItem = [MKMapItem mapItemForCurrentLocation];
MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake([natObject.latitude doubleValue], [natObject.longitude doubleValue]) addressDictionary:nil];
MKMapItem *destinamtionLocItem = [[MKMapItem alloc] initWithPlacemark:place];
destinamtionLocItem.name = [natObject name];
@NikolaKirev
NikolaKirev / android_action_bar.java
Created Apr 6, 2013
Android Tutorial:Adding buttons in the action bar part 2
View android_action_bar.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
@NikolaKirev
NikolaKirev / android_action_bar.xml
Created Apr 6, 2013
Android Tutorial: Adding buttons in the action bar part1
View android_action_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/itemAdd"
android:icon="@drawable/add"
android:showAsAction="ifRoom|withText"
android:title="@string/btnAdd">
</item>
<item
android:id="@+id/itemRefresh"
@NikolaKirev
NikolaKirev / FizzBuzz.m
Last active Dec 15, 2015
Objective-C: FizzBuzz
View FizzBuzz.m
- (void)fizzBuzzToNumber:(NSInteger)endNumber {
for (NSInteger i=1; i <= endNumber; i++) {
if (i % 3 == 0) {
if (i % 5 == 0) {
NSLog(@"FizzBuzz");
}else {
NSLog(@"Fizz");
}
}else if (i % 5 == 0) {
NSLog(@"Buzz");
@NikolaKirev
NikolaKirev / gist:5236003
Created Mar 25, 2013
Simple UIView ANimation with blocks - iOS
View gist:5236003
[UIView animateWithDuration: 0.9 delay: 0 options: UIViewAnimationOptionCurveEaseInOut animations: ^(void)animations{
CGPoint newCenter = CGPointMake(self.greenView.center.x + 180, self.greenView.center.y + 260);
[self.greenView setCenter: newCenter];
}completion:^(BOOL finished){
//this code is called after the aminations have completed
}];
@NikolaKirev
NikolaKirev / NSPredicateFiltering
Created Feb 13, 2013
Filtering an array with NSPredicate
View NSPredicateFiltering
NSString *companyName =@”Apple”;
NSPredicate *predicate =[NSPredicate predicateWithFormat:@"company == %@", companyName];
NSArray *filteredArray =[originalArray filteredArrayUsingPredicate: predicate];
You can’t perform that action at this time.