The Background
I'm developing an app that has a Status Window; its purpose is to show various errors that might appear during the app's lifecycle:
As you can see from my quick mockup, each error can be interacted with. For instance, touching an error related to settings might switch to the Settings UIViewController. Other errors might be "status-only" -- touching those might merely remove them from the Status Window.
The Question
Will you point me toward an appropriate method of storing these messages and their related actions? I'm swimming in the possibilities. I want these errors to be persistent, so something like Core Data seems to make sense (although, in my heart of hearts, Core Data seems really immense and perhaps unsuited for something this "simple").
Thanks for helping!
Core Data seems overkill for this. I think the suggestion with NSUserDefaults is a reasonable one.
You could construct an NSArray and store in it the error dictionaries with numbers and strings. Seems straight-forward enough.
Related
I'm programming in iOS not so long. I was mainly programming UI related stuff like animations, custom UIControls etc.
I need in my new app to:
Display loading activity indicator and in the same time:
load some remote data from server parse them and store in local core data
load some data from local core data
get user position from location service
After this I have all data needed to display next view controller and dismiss loading indicator.
Question is how can I do this all? I need to support iOS9, iOS10, 11, 12. I understand that this needs to be done in background threads and then I need to merge all data from each task and switch to next view controller. I can't use any external libraries like rx-swift or promise-kit. Maybe there is any experienced iOS developer who can give me some main guidelines how to approach to this kind of application flows? I can imagine there is a lot of ways I can do it some of them are better and some of them are worse. Any guidelines would be very helpful for me. Thanks.
It's a very complex question and as you said it's possible to solve all this problems in several ways. But for sure i can give you some core-hints about which steps is better to follow:
Run in a separate thread the management of all stuff regarding to the Network communication. Maybe you can run it on a separate queue using the class DispatchQueue(). Once you received the data, in the same thread, maybe you can directly convert these information and store them inside a CoreData database.
To store into CoreData you need at first to know how it works, so basically search for some really easy tutorial about how to create from zero your first database inside XCode. After you have been able to run and execute a very simple one you will be able to pass to the second step and so try to integrate it with the data you have previously downloaded from the network. Here a good article for you: https://www.raywenderlich.com/7569-getting-started-with-core-data-tutorial .
To get the location is a separate field of study, because you have to study which background modes are allowed in iOS (And actually are allowed just a few). After that you will need to figure out in which category of background-location application your software belongs. After that you have to dig deep and discover how protocol and delegates works inside Swift/Objective-C in order to properly manage the last location value retrieved by the sensors. Here is a good article for you: https://www.raywenderlich.com/5247-core-location-tutorial-for-ios-tracking-visited-locations.
At the end when you interconnected all this flows you can think about how to display the loading indicator. Basically you need to drag and drop it from the tools into the storyboard, interconnect it by using the IBAction or IBOutlet, depending on when you wanna show it and in which specific case. And then use the relative method startAnimating or stopAnimating in the right code flow (It really depends on how you have structured all the previous bullet points).
Since your question was very general and it includes a lot of sub-steps, basically it really needs to be thorough studied and analysed.
I've tried to sum up as much as possible the most important bullet points. I hope the links i suggested to you will help a little bit. Good luck.
I'm working on a patch in Pure Data which uses an 8 number scale to decide which chords can be played. E.g. if a chord uses a note that is not in the scale, re-roll. Obviously this isn't the most musical soultion as we usually expect accidentals and such, but here we are looking at a primitive method for procedural music. Here is the problem patch:
CreateChords patch
As soon as I attempt to use a new scale, pure data freezes and requires an immediate restart.
Any suggestions would be greatly appreciated.
Thanks,
Liam
It would be massively more efficient and easier to use an object like [coll] or [textfile] to store your chord patterns. Instead of having each pattern in a message object, which you then need to feed individually through all of the processing, you would just have one object, and feed your random number generator into it, which will then spit out the corresponding code. something like this
your patch reworked
there you have it. A spaghetti mess of wires and boxes reduced to 11 objects and 11 cables. There are several other ways to accomplish similar things, but this was the first to come to mind. If this one works for your purpose, cool, or else lemme know and I'll show you other ways.
Ah, yea, I suspected a stack overflow as the cause of the crash. It's easy to make that mistake with so many wires so close together, as it's hard to see what all has been connected or mis-connected. Accomplishing this idea using only vanilla objects is quite a bit more challenging, now that you mention it. Here's something that could possibly work.
I'm working on a new iOS app and I keep reading things online such as, "All apps that use backends should use CoreData". I haven't been able to find to many reasons backing up this logic. Are there any reasons that I am not realizing for why I should use CoreData in an application if the content is constantly changing and I don't need to sort or access the data offline? I have gotten CoreData to work, I just don't fully see the benefit be is ease or performance. Would anyone mind shedding some light on this topic?
You don't have to use it.
Some reasons you might use it in the case you've described:
If you have a lot of data, too much to keep in memory on the device
If you want undo–redo support
You want support for fancy querying
I have been tasked with creating an iPhone application for a client.
I have some coding experience but only in C# so it doesn't really help here but other than that I am a complete novice on iPhone coding.
What I am trying to accomplish is to get some form of store locator on a map.
I have successfully added the map, get the user location with it zooming into the user. I have added 2 annotations (Which I believe the the best way to go about showing locations on the map).
I have 2 queries that I need help with, What is the best way to go about listing the stores in some form of database. XML, PList, .sql etc... (this would also need to be read from the web as it would need to be easily edited as new stores would be added a lot). Is it possible to loop through the database and dynamically add the stores onto the map within a location of the user?
I am not asking anyone to write any code for me, I am just asking for some help as I have googled the hell out of this and cant seem to find anything that helps.
Any help would be much appreciated,
Thanks
In terms of your potential formats for saving these locations, you options include:
XML/JSON are good formats for exchanging data with a remote server, but less ideal for a local database (though they theoretically could be used for that purpose). JSON is marginally easier to deal with (using NSJSONSerialization), but XML can be relatively easily parsed, too (using, for example, NSXMLParser). If you're doing network operations, I also heartily recommend looking at AFNetworking, which offers some nice advantages over the standard NSURLConnection. This, of course, presumes that you have written a web service on your server to deliver the necessary JSON or XML feed.
Plist is a fine, simple format if you want to save a short, local list of locations on iOS devices. Saving data to a plist is as simple as calling writeToFile method for your NSDictionary or NSArray and reading data is done via [NSDictionary dictionaryWithContentsOfFile:filename] or [NSArray arrayWithContentsOfFile:filename].
Core Data is a good, iOS-specific format for larger databases. It's probably the preferred iOS mechanism for dealing with persistent objects, but is an order of magnitude more complicated than plists.
SQLite is also a good database format if you're thinking about a structure that lends itself towards larger database, but also which lends itself towards eventual rollout to multiple platforms (e.g. both Android and iOS). If you decide to go SQLite route, consider an Objective-C wrapper (such as FMDB), which will simplify your life greatly.
Implicit in all of the above discussion is that, yes, you certainly can write code that iterates through your database and/or model data structures, extracting the necessary location information, and dynamically add annotations to your map. The Location Awareness Programming Guide should help introduce you to some of the MapKit related features.
"Is it possible to loop through the database and dynamically add the stores onto the map within a location of the user?"
Yes. Just as you have created those first two annotations, you now need to create more annotations in a loop. The only additional info you might need is that once you have added an annotation to the map it will stay there until you remove it. So you don't need to maintain your own list of annotations unless you want to do something else with it. Just fire and forget. So now your question comes down to how to loop through data from your chosen data source in Objective-C and not MapKit specific.
I know this is old but if anyone else comes across this like I did, you can use tmysqlkit by tanmay bakshi to read and write directly to a mysql database on a server.
Best,
Sam
In beta testing an iOS application I wrote, I received some feedback to let more elements 'bounce', even if there isn't more content to see, or load in.
While I don't think its necessarily a bad suggestion it got me thinking - what is the purpose of allowing this behavior on UI elements? Is this stated in the HIG somewhere that I missed?
If the list bounces you know that it is at the end instead of just frozen or something. It feels good to get feedback whenever you touch something even if nothing is happening.
While this question is better suited for http://programmers.stackexchange.com, I shall answer it the best I can here:
It gives the user feedback that something is happening
It helps to prevent the user from accidentally doing something they may not want to do (cancel editing, delete important data) etc.