Comment by kubi on Swift outlet collection - 'IBOutlet' property cannot be an...
Can you post the definition of Badge? It looks like Badge is a struct, not a class.
View ArticleComment by kubi on "Does not conform to protocol" error when extending...
My protocol specifies one function, which returns a URLSessionDataTask. NSURLSession has the same function, except it returns a NSURLSessionDataTask, which adopts URLSessionDataTask, so I would expect...
View ArticleComment by kubi on How do you dismiss the keyboard when editing a UITextField
Helpful class. One small point, you shouldn't prefix your own classes with "UI". In objective-c you should use your own prefix ("TL"?), in Swift, don't use anything.
View ArticleComment by kubi on Accessing the host app code from the Xcode 7 UI Test target
Like @Konnor says in their answer, you can't access your app's process from within a UI test. What are you trying to do? I've had some success working around these limitations in our tests.
View ArticleComment by kubi on Accessing the host app code from the Xcode 7 UI Test target
If you figure something out, write a blog post! i'm sure a lot of people would be interested. I think the way forward might be to make an API call to a local server. Sounds a bit complicated, but I bet...
View ArticleComment by kubi on "Infinite Drill-down" with UINavigationController
I don't know what has replaced, but unloading view controllers hasn't been part of iOS for years now, so my answer is a bit outdated.
View ArticleComment by kubi on Is it possible to refresh a single UITableViewCell in a...
@happiehappie beginUpdates() and endUpdates() consolidate a bunch of changes into a single animation. If you're only doing one reload, there's no need to consolidate anything.
View ArticleComment by kubi on Printing optional variable
I think the example would be slightly better if you changed it to use if let age = age { return ""} else { return "" }
View ArticleComment by kubi on Crash at NSOperationQueue addOperation Custom NSOperation
Did you ever find out what was causing this crash? We're seeing the same crash in our app.
View ArticleComment by kubi on Crashed: com.apple.main-thread when setting value on...
Carloshwa did you get anywhere with this crash? I'm seeing a similar crash in my own code.
View ArticleComment by kubi on Custom pattern matching fails with `Enum case is not a...
Thanks @hamish! Do you want to add this comment as an answer and I'll accept it?
View ArticleComment by kubi on How do you dismiss the keyboard when editing a UITextField
@IulianOnofrei The default behavior of the return button is to add a line return and keep the keyboard onscreen. By returning NO you avoid adding a line return to the text.
View ArticleAnswer by kubi for How to enable automatic method suggestion in swift in Xcode?
If you're referring to autocomplete, Swift does have autocomplete, but it's buggy and sometimes breaks. If it's not working, try deleting the derived data for your project and letting it re-index. The...
View ArticleAnswer by kubi for How to push a local Git repository to another computer?
Here's a script that I wrote to do just this thing. The script handles all my usual initialization of new git reposcreates .gitignore fileinitializes .gitcreates the bare git repo on the serversets up...
View ArticleAnswer by kubi for Swift - How do you cast a CVImageBufferRef as a...
@LombaX's solution didn't work for me in the latest build, Xcode Beta5. Here's what did work:let imageBuffer : CVImageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)let srcPtr =...
View ArticleWhat do the contents of the general purpose registers contain?
I included the iOS tag, but I'm running in the simulator on a Core i7 MacBook Pro (x86-64, right?), so I think that's immaterial.I'm currently debugging a crash in Flurry's video ads. I have a...
View ArticleWhat type is the function input to String.withCString()?
I'm using the function String.withCString() as follows:let s = "Hey!"let c = s.withCString { strlen($0)}println(c)However, if I add a second line to the withCString closure, I get an errorlet s =...
View ArticleCan I return typed objects from a Dictionary?
Here's what I have right now:enum TestKeys: String { case login = "login" case username = "username"}var testData: Dictionary<String,AnyObject> = // a dictionary of known key/values// I want the...
View ArticleAnswer by kubi for Dynamically load nib for iPhone/iPad within view controller
EDIT: @Adam's answer below is the correct answer.To determine which nib to load, do the following, and scrap your initWithMyLovelyData method and use a property to set the data. You should be able to...
View ArticleAnswer by kubi for Xcode: issue "file xxx.png is missing from working copy"...
In my case, Xcode had somehow found old .svn directories that referenced the missing files. I had to go up a level above my project folder to find those .svn files. Once deleted, I restarted Xcode and...
View ArticleAnswer by kubi for Subclassing UIButton to handle clicks
I think there are better solutions to this problem than what you've proposed, but to answer your question directly: A subclass of UIButton observes touch events the same way that everyone else observes...
View ArticleAnswer by kubi for Convert a bit array to a struct array in Swift
Thanks to @GoZoner's hint, I found this thread on Apple DevForums. Below is my final, working, solution.struct Pixel { let r: UInt8 let g: UInt8 let b: UInt8 let a: UInt8}let data: CFData! = ...let...
View ArticleAnswer by kubi for '[CLPlacemark]?' is not convertible to '[CLPlacemark]' ->...
In Xcode 7.0, Objective-C has generic arrays, so your placemarks array is no longer [AnyObject]? but is now [CLLocation]?. You don't need to cast the array, you can just unwrap the optional. With the...
View ArticleAnswer by kubi for "Does not conform to protocol" error when extending...
What I ended up doing was creating a protocol extension that creates the necessary method that NSURLSession requires.extension NSURLSession : URLSession { func dataTaskWithURL(url: NSURL,...
View ArticleAnswer by kubi for Lexical or Preprocessor Issue error (UIKit/UIKit.h file...
I was having the same issue with a framework target, building for iOS. I solved this by setting the "Base SDK" in my build configs to something reasonable.
View ArticleUITests in Xcode 7 finds wrong 'Next' button
I have a test that looks like the following:func testNextButtonDisabled() { let app = XCUIApplication() XCTAssertFalse(app.buttons["Next"].enabled)}This test fails because, in addition to my own "Next"...
View ArticleAnswer by kubi for UITests in Xcode 7 finds wrong 'Next' button
The specific solution to this problem is to look for elements that are descendants of the main window.func testNextButtonDisabled() { let app = XCUIApplication()...
View ArticleConvert a bit array to a struct array in Swift
Here's what I've got currently. I'm wondering if there's a more elegant way to do it or, better yet, a way to cast my array to the required type without iterating over the entire structure. My input is...
View ArticleAnswer by kubi for How to handle drag events on iphone and ipad with...
Apple's Developer pages have a lot of good info on handling just these types of issues.Handling Events
View ArticleAnswer by kubi for Objective C: Send email without leaving app
Yes. Use the MFMailComposeViewController.// From within your active view controllerif([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailCont = [[MFMailComposeViewController...
View Articlegrep'ing output from continuously updated output
I'm trying to write a simple script around Lame to customize the program for my specific uses. What I'd like to do is parse out just the percent completeness from the Lame output.Here's what the line...
View ArticleAnswer by kubi for How can I detect if an iPhone is rotating while being face...
When the phone is stationary the sum of the acceleration vectors should be +1. When the phone is rotating (assuming the sensor is off-center) the sum of the vectors should be more than 1 and...
View ArticleAnswer by kubi for How to .gitignore all files/folder in a folder, but not...
You can't commit empty folders in git. If you want it to show up, you need to put something in it, even just an empty file.For example, add an empty file called .gitkeep to the folder you want to keep,...
View ArticleSQL Server database change workflow best practices
The BackgroundMy group has 4 SQL Server Databases: ProductionUATTestDevI work in the Dev environment. When the time comes to promote the objects I've been working on (tables, views, functions, stored...
View ArticleUIImagePickerController doesn't fill screen
I'm adding a custom overlay to the UIImagePickerController and there is a persistant black bar at the bottom of the view. Here is my code to instantiate the controller.- (UIImagePickerController...
View ArticleCan you attach a UIGestureRecognizer to multiple views?
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)];[self.view1 addGestureRecognizer:tapGesture];[self.view2...
View ArticleHow do you dismiss the keyboard when editing a UITextField
I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there a...
View ArticleWhat is the best practice for dealing with passwords in git repositories?
I've got a little Bash script that I use to access twitter and pop up a Growl notification in certain situations. What's the best way to handle storing my password with the script? I would like to...
View ArticleAnswer by kubi for Git is very very slow when tracking large binary files
Garbage collect:git gcThis makes a significant difference in speed, even for small repositories.
View Article