Skip to content

Instantly share code, notes, and snippets.


Nikola Kirev NikolaKirev

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 / 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: @",%f&daddr=%f,%f",
[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
[self presentViewController:activityVC animated:YES completion:nil];
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 / 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]; = [natObject name];
NikolaKirev /
Created Apr 6, 2013
Android Tutorial:Adding buttons in the action bar part 2
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(, menu);
return true;
public boolean onOptionsItemSelected(MenuItem item) {
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="" >
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) {
}else {
}else if (i % 5 == 0) {
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( + 180, + 260);
[self.greenView setCenter: newCenter];
}completion:^(BOOL finished){
//this code is called after the aminations have completed
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.