Tag: swift

CIAreaHistogram gives me all 0 except the last element?

I want to calculate histogram of an NSImage, so I turned to CIFilter naturally. There’s a filter named CIAreaHistogram does what I want. Here’s my code: NSBitmapImageRep *rep = [image bitmapImageRepresentation]; CIImage* hImage = nil; @autoreleasepool { CIImage *input = [[CIImage alloc] initWithBitmapImageRep:rep]; CIFilter *histogramFilter = [CIFilter filterWithName:@”CIAreaHistogram”]; [histogramFilter setDefaults]; [histogramFilter setValue:input forKey:kCIInputImageKey]; [histogramFilter setValue:[CIVector […]

iOS – UINavigationController, Hide navigationBar

I have a minor trouble hiding the navigationBar for my UINavigationController I have added: self.navigation!.navigationBar.hidden = true This, unfortunately leaves some kind of background (white) left behind the white status bar that pushes the content (green) downwards, and an unwanted scroll behaviour where I can drag the content up and down to show/hide the white […]

Swift class using Objective-C class using Swift class

I have an obj-c project to which I successfully added a new Swift class A, which is being used by some existing obj-c class B – the use of the automatically generated “MyProject-Swift.h” header worked as expected. I also successfully added a new Swift class C that uses some existing obj-c class D – the […]

UICollectionView items disappear when scrolling with my own UICollectionViewFlowLayout subclass

Context: I am using an UICollectionView for a photoview. Every picture is a cell with one UIImage. Images can have different sizes and I want them to fill the whole screen. So I wrote a class who determines the frame of every single UICollectionCell and let a subclass of UICollectionViewFlowLayout ask that class for the […]

How to use Swift App + (Swift Framework + Objective C static Framework) without warnings

What I am trying to do: Create a swift dynamic framework – Say SwiftDemo.framework Swift.framework depends upon an external Objective-C static framework (No source code available) – Say ObjCDemo.framework. This framework has it’s module file and placed inside ObjCDemo.framework/Modules/module.modulemap Put this SwiftDemo.framework inside an Swift application. Ideally I would want my swift app to be […]

NSOpenPanel in Swift . How to open?

I have this Objective-C Code : – (IBAction)selectFileButtonAction:(id)sender { //create open panel… NSOpenPanel* openPanel = [NSOpenPanel openPanel]; // NSLog(@”Open Panel”); //set restrictions / allowances… [openPanel setAllowsMultipleSelection: NO]; [openPanel setCanChooseDirectories:NO]; [openPanel setCanCreateDirectories:NO]; [openPanel setCanChooseFiles:YES]; //only allow images… [openPanel setAllowedFileTypes:[NSImage imageFileTypes]]; //open panel as sheet on main window… [openPanel beginWithCompletionHandler:^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) { […]

Inter-operability of Swift arrays with C?

How can one pass or copy the data in a C array, such as float foo[1024]; , between C and Swift functions that use fixed size arrays, such as declared by let foo = Float[](count: 1024, repeatedValue: 0.0) ?

Converting UIColor to CGColor in swift

This is the Obj-C code: CGContextSetStrokeColorWithColor(context, [[UIColor lightGrayColor] CGColor]); How do I write it in swift.

Want to add event in google calendar

I want to insert event in google calendar without using any third parties. Please help me if any one know it. Thanks in advance.

Convert Base64 GZipped string Objective-c or Swift

I received a string from a web service like this: CAAAAB+LCAAAAAAABADtvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyJOp/PqTf6u/X8A1v85+wgAAAA= The source string was “EchoText” that compressed with Gzip then converted to Base64. I have to decode Base64 string at first then Unzip that using Gzip. How can I do in Swift (or Objective-C)? Edit: I found a good library for using Gzip: nicklockwood/Gzip […]