iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

UIGraphicsGetImageFromCurrentImageContext memory leak with previews

I’m trying to create previews images of pages in a PDF but I have some problems with the release of memory. I wrote a simple test algorithm that cycles on the problem, the app crashes near the 40th iteration: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@”myPdf.pdf”]; […]

Prepare for Segue in Swift

I’m facing the error message: “UIStoryboardSegue does not have a member named ‘identifier'” Here’s the code causing the error if (segue.identifier == “Load View”) { // pass data to next view } On Obj-C it’s fine using like this: if ([segue.identifier isEqualToString:@”Load View”]) { // pass data to next view } What am I doing […]

Convert string with unknown format (any format) to date

I have data that contains a date string. Normally it would be in a ‘Jan. 3, 1966’ type format, but because of international differences, it may not always be exactly that. I need to read the data in and convert it into a standard date string (‘YYYY-MM-DD’). Basically this is what I have so far: […]

Undefined symbols for architecture x86_64 on Xcode 6.1

All of a sudden Xcode threw me this error at compilation time: Undefined symbols for architecture x86_64: “_OBJC_CLASS_$_Format”, referenced from: objc-class-ref in WOExerciseListViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) After doing some research, I may understand that a library I’m […]

iOS 10 error <private> when using UIImagePickerController

I am using XCode 8 and testing with iOS 10.2 Beta. I have added the Photos, PhotosUI and MobileCoreServices frameworks to project. Very simple code: #import <Photos/Photos.h> #import <PhotosUI/PhotosUI.h> #import <MobileCoreServices/MobileCoreServices.h> @interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, PHLivePhotoViewDelegate> @property (strong, nonatomic) IBOutlet UIImageView *imageview; @end and implementation: – (IBAction)grab:(UIButton *)sender{ UIImagePickerController *picker = [[UIImagePickerController alloc]init]; […]

Retrieve all contacts phone numbers in iOS

So far I saw methods to get multiple phone numbers if I show a picker so user can select people and then get the phone number. What I want is retrieving all contacts‘ numbers. Is it even possible?

CoreData relationship fault?

I have an Order which has a “to-many” relationship with Units. When I try to log the units (NSSet) in Order, I get a fault error: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@”Order” inManagedObjectContext:mainContext]; [fetchRequest setEntity:entity]; NSArray *fetchedObjects = [mainContext executeFetchRequest:fetchRequest error:nil]; for (Order *order in fetchedObjects) { NSLog(@”%@”, [order units]); […]

Array from dictionary keys in swift

Trying to fill an array with strings from the keys in a dictionary in swift. var componentArray: [String] let dict = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource(“Components”, ofType: “plist”)!) componentArray = dict.allKeys This returns an error of: ‘AnyObject’ not identical to string Also tried componentArray = dict.allKeys as String but get: ‘String’ is not convertible to [String]

Add views in UIStackView programmatically

I’m trying to add views in UIStackView programmatically. For now My code is: UIView *view1 = [[UIView alloc]init]; view1.backgroundColor = [UIColor blackColor]; [view1 setFrame:CGRectMake(0, 0, 100, 100)]; UIView *view2 = [[UIView alloc]init]; view2.backgroundColor = [UIColor greenColor]; [view2 setFrame:CGRectMake(0, 100, 100, 100)]; [self.stack1 addArrangedSubview:view1]; [self.stack1 addArrangedSubview:view2]; When i deploy the app, there is only 1 view […]

Is it possible to change color of single word in UITextView and UITextField

Is it possible to change color of single word in UITextView and UITextField ? If i have typed a word with a symbol infront (eg: @word) , can it’s color be changed ?