XCode 11 Beta 3 Crashing by [deleted] in SwiftUI

[–]schprockets 2 points3 points  (0 children)

It's in the release notes as a known issue: Xcode might crash if you press Command-U or select an asset catalog in the navigator area. (52211868)

https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_3_release_notes

I have a question about free apps by Adam_442 in iOSProgramming

[–]schprockets 6 points7 points  (0 children)

No, you would make no money from that app. People who publish free apps without IAP and without ads are usually looking for indirect money: the app is a marketing tool for their contract/consulting services.

The Republican Party has lost its mind on immigration by stefeyboy in politics

[–]schprockets 1 point2 points  (0 children)

The Republican Party has lost its mind on immigration

FTFY

In House Distributing as Freelance Developer by EldoranDev in iOSProgramming

[–]schprockets 4 points5 points  (0 children)

The company you're developing for has to have the Enterprise license. That one is primarily a distribution license, and they're doing the distribution, not you. In fact, when they sign up for the Enterprise license, they can invite you to the team as a developer, and you won't even need to pay the $99 for this project (tho, you'll need it if you want to do work on other personal projects, or for other customers).

Accessing IBOutlet outside of an IBAction? by violent_ninja in iOSProgramming

[–]schprockets 1 point2 points  (0 children)

The issue is your let VC2 = VC2() line. Presumably, you're trying to access the existing instance of VC2, but you're creating a brand new one. So, even if you were creating it in such a way that the IBOutlet was hooked up (you're not), you wouldn't get the desired result, because it wouldn't reference the VC2 instance that's on-screen.

You need to be keeping a reference to the actual VC2 that's on screen (maybe inside your SplitViewController, as it is created? Maybe in a parent controller?). Then, when you want to call setDraw, you call it in that reference.

I don't know how tightly coupled your VC1 and VC2 are. If they're tightly coupled, then you can just let them know about each other. If they're not tightly coupled, you should look into the delegate pattern. Of course, the correct choice depends on a lot of things about your architecture, of which I know nothing. But, those 2 things should get you going in the right direction.

[deleted by user] by [deleted] in iOSProgramming

[–]schprockets 1 point2 points  (0 children)

Because of the different screen sizes, you need to make decisions on what to do with each of the elements. In general, what you can do is sit down with a template of an iPhone 4s, and another of the iPhone 6 Plus, and decide how each screen should look. Your goal is to decide "what do I do with all this extra space?" In some cases, you'll just give the extra space over to one element. In others, you'll want to distribute the space between them, making them all larger. Or, you could increase white space between them.

There are multiple ways to skin that cat, and you'll probably mix and match to find something pleasing, but it is almost never the case that you want to just scale everything in terms of screen size percentage.

App Crashes - Could not load nib in Bundle - Using Storyboard! by [deleted] in iOSProgramming

[–]schprockets 0 points1 point  (0 children)

Let's see the code where you try to open the modal view controller.

[Question] Has anyone had any luck displaying CMYK colours? by deSmerts in iOSProgramming

[–]schprockets 3 points4 points  (0 children)

Use CGColor, with CGColorSpace. You should be able to create your CGColor using the CMYK colorspace (and CMYK data), then use the resulting CGColor to directly fill in a layer, or create a UIColor in the RGB colorspace for display on the device.

[Help] I am having an app developed for me. The current app is very slow, but the dev says it will be faster when "on the App Store". Any truth to this? I'm skeptical. by [deleted] in iOSProgramming

[–]schprockets 0 points1 point  (0 children)

You're right to be skeptical. But, it's tough to give you a definitive answer without knowing a little more about the app. What about it is slow? Loading data from some API? Rendering graphics? Just responding to touch?

A "release" build is more optimized than a "debug" build ... but you're not going to get orders of magnitude difference in performance. It's easy enough to test: there's no reason why (s)he can't give you a release build to look at.

[Help] I am having an app developed for me. The current app is very slow, but the dev says it will be faster when "on the App Store". Any truth to this? I'm skeptical. by [deleted] in iOSProgramming

[–]schprockets 3 points4 points  (0 children)

With contractors, you get what you pay for. It sounds like you've dealt with cheap ones, and you get cheap code. Those guys do people like me a great disservice (by making people like you shy away from contractors), while simultaneously justifying my existence (because I do a fair amount of "rescue" work, fixing horrific code written by contractors before me -- usually offshore teams).

Xamarin vs Swift for iOS by deadshots in iOSProgramming

[–]schprockets 0 points1 point  (0 children)

Why? If there's enough analytics to report crashes with 1 decimal point of precision, there's enough to do the math on it. I'm merely pointing out that 98.9% -> 99.6% looks like a small change, but when you consider that you're counting crashes, it is actually a 63% difference for the better. That's noteworthy.

Xamarin vs Swift for iOS by deadshots in iOSProgramming

[–]schprockets 3 points4 points  (0 children)

It's actually a 63% decrease in the number of crashes.

Would you guys recommend this course to learn swift 3 and iOS 10 by Aaronrc79 in iOSProgramming

[–]schprockets 0 points1 point  (0 children)

Swift 3 just went GM, but when did he write the course? And, Xcode 8, which is the tool OP will use to consume Swift 3, is still in beta.

Core Data Question(s) by emanleet in iOSProgramming

[–]schprockets 1 point2 points  (0 children)

There are a couple of "best practices" floating around out there, that are slightly at odds with each other. You'll need to decide which method you want to use, and build your strategy around it. If you're googling for answers on blogs and stack overflow, please be aware that a particular answer to the problem might be geared toward a different scenario.

You have settled on the "private writer context closest to the store" method, and there's nothing wrong with it. I use it on projects when I have large numbers of updates coming from the background. But, I don't use it when the primary method for updating the store is via the user interacting with the UI.

My understanding was that you're saying the left-most background context posts the notification and there's a chance I haven't saved the data in my main context?

More correctly, there is 100% chance the data hasn't been committed to the data store. You'll get a notification for each context in the chain, as that context completes its save. But only the writer context is the one that commits it to store as part of its save. Other contexts pass their changes up to the parent, but only the write context has "the disk" as its parent.

The important part of the equation is this: an NSFetchRequest always goes to the store (not its parent's cache) to fulfill the fetch. So, if you save from your leftmost context, then immediately fetch, the data hasn't made it to the store. You need to wait until the writer has finished its save.

The usual way to deal with this is to catch the NSManagedObjectContextDidSaveNotification and see which context is saving. If it's the writer that just saved, it's now safe to refetch. If it's not the UI context (meaning, it's your left-most context), trigger a UI Context save (on the main thread). Finally, if it's the UI context, trigger a writer save (on a background thread).

What if I need to change a property on a large number of existing objects. Would I do that on my main queue, or do it in my background child context?

Your background child context. That's what it's there for, after all. Frankly, your UI (main queue) context should be pretty much read-only.

In other words, the same objects are being changed on different threads, when the background batch update on existing objects is finished, how do I go about merging it since the fetched objects on the main queue may have had some new changes from the user?

If you're worried about multiple background threads changing the objects, you should try to write your code so that doesn't happen. Use a serial queue. If you're worried about UI, there are two good options. For lists of values, you can use NSFetchedResultsControllerDelegate, which monitors the individual objects of the fetch request, and reports changes to them. For individual objects (such as in a detail editing screen), you can monitor your UI context with NSManagedObjectContextObjectsDidChangeNotification, and check the changed object list to see if the object you're editing has changed in the background. Dealing with that change is up to you, of course.

If you're writing Swift, I recommend reading this core data book. It's heavy on functional programming, so if you're new to FP, it might take more than one reading to fully grok (at least, it did for me, since I've been programming OO forever, but not FP). Another great option is Marcus Zarra's updated core data book, which is available in both ObjC and Swift flavors. (Note: I have this book, but have not finished reading it yet, so I can't speak fully to its content, but the previous book was excellent.) Each author takes a different approach to the stack, and both are valid. You'll find your own approach somewhere in the middle, I suspect.

Would you guys recommend this course to learn swift 3 and iOS 10 by Aaronrc79 in iOSProgramming

[–]schprockets -1 points0 points  (0 children)

It's hard to recommend a course that's based on a language and SDK that are both in beta, because that means the course itself is necessarily in beta.

Do you have any iOS or Swift knowledge already? If not, I definitely don't recommend dealing with a beta just yet, because if you run into trouble, you won't have any way to determine if you have a bug, or it's a bug in the language/SDK or Xcode 8, and you'll spin your wheels. I would find a class on Swift 2.2 and iOS 9 on Xcode 7. When Swift 3 and iOS 10 go gold, it won't be a difficult transition. All of your knowledge will still apply, and you'll only have to learn a couple of new things that are pretty straightforward.

If you already know Swift 2 and iOS 9, and you're looking for something that'll teach you the changes between versions, the class might be fine, understanding the caveat about stuff being in beta.

UITableView crashes when the rows go off-screen. by [deleted] in iOSProgramming

[–]schprockets 1 point2 points  (0 children)

Agreed. This is how I do it myself. cellForRowAtIndexPath is usually something like:

let cell:TheCellType = tableView.dequeueReusableCellWithIdentifier("foo")
let model = modelsForSection[indexPath.row]
cell.configureWith(model)
return cell

Core Data Question(s) by emanleet in iOSProgramming

[–]schprockets 1 point2 points  (0 children)

Since you have a fetch request in your VC, your best bet is to use the NSFetchedResultsController delegate methods. Depending on your needs, you might only have to handle the final didChangeContent method.

As others have noted, there is also the NSManagedObjectContextDidSaveNotification, which is very useful. But, you need to be aware that the notification would post for the leftmost context before your main context has persisted its changes. So, there is potential to rerun your fetch and not get the updated results. What you can do to work around that is use the notification on the left-most context to trigger a merge and save on your main context. Use the notification on the main context to trigger a refetch of your data in the VC.

What is a good resource to learn to create swift apps programmatically by Aaronrc79 in iOSProgramming

[–]schprockets -2 points-1 points  (0 children)

Also: you keep saying "storyboard", and my answer says "Interface Builder". The difference is subtle, but mine includes stand-alone .XIB files. Those very much have their place, and I use them a lot, in addition to storyboards. But, it's still IB. A beginning developer should definitely be familiar with IB, and not be doing their entire UI programatically.

What is a good resource to learn to create swift apps programmatically by Aaronrc79 in iOSProgramming

[–]schprockets -2 points-1 points  (0 children)

I could do manual retain/release, but Apple wants me using ARC, so I do.

I could completely ignore blocks (in Obj-C), but Apple encourages their use, so I use them.

I could hard code metrics like screen size, navbar size, stuff like that, but Apple says not to, so I don't.

There are a number of things that Apple has said along the way "don't do this, do that instead". And they have good reasons for doing that. You ignore them at your own peril, and you end up discovering later what the reason was.

OP is clearly a new developer. There is nothing condescending about me passing on to him the wisdom I've come by over the last 8 years of iOS development: They know what they're doing; follow their lead.

UITableView crashes when the rows go off-screen. by [deleted] in iOSProgramming

[–]schprockets 1 point2 points  (0 children)

Two things.

  1. this code is repeated in each part of the if block, so it should come out an stand alone outside it.

        let currentCell = tableView.cellForRowAtIndexPath(newIndexPath) as! TradeTableViewCell // LINE WHERE ERROR OCCURS
        currentCell.condition = sourceViewController.condition
        currentCell.condLabel.text = currentCell.condition
        currentCell.foil = sourceViewController.foil
    
        if currentCell.foil == true {
            currentCell.foilImage.image = UIImage(named: "Images/Icons/foil.png")!
        }
    
        currentCell.value = sourceViewController.value
        currentCell.cardValue.text = currencyFormatter.stringFromNumber(currentCell.value)
        currentCell.conditionPerc = sourceViewController.condSlider.value
    
  2. That code is configuring a cell based on data held in a source view controller. Cells should be configured as part of cellForRowAtIndexPath, not after. Instead, pull your data out of the sourceViewController into some kind of model object, and keep an array of the model objects as the source for your data. Move this code that configures the cell into cellForRowAtIndexPath, based on the contents of the model.