How to use CoreData with two view controllers one of them has collection view - ios

First of all, I am new in coding, so please be patient with me.
My app has two view controller, the first has UICollectionView and the second has UITextField.
I am trying to tap on one of these collection view cells and then it takes me to the second view controller, where I can type in the textView then save it into CoreData. And then when I go back and press on the same cell i get my saved text. Then when i change this text on the ui text view.. it saved automatically.
Can any one give me an example or put me in the right track

The essence of how that might be done is to implement the collectionview delegate and then determine which cell they clicked on, so that the next screen loads/and updates the correct data. After they click you would call the "segue" with some code. The segues are setup in Xcode's visual editor by control click and dragging a line to the second view. (It's weird, there are some great youtube videos out there) The data would be stored in an array. After you update the data, you could dismiss the second view and the collectionview behind it would be visible again.
I would check out chapter 4.5 of the free iBook "App Development with Swift". Chapters 4.5-4.8 would really get your rocking the right path. If that book is too complex then also look into "Intro to App Development with Swift"
I even have some videos to take you through the process, dunno if I have one for 4.5 but if you continue with it, I have one for 4.6.
https://www.youtube.com/watch?v=Q5u9SGhQoPY&t=2254s

Related

iOS swiping/paging between detail pages of Collection View Items

I am working on an iOS app using Xcode 10 and Swift 4.2. I have a collection view that has images and once you tap on the image it takes you to a detail page that has the full-sized image, date and saying displayed. The data for these details are stored in an array and passed from the collection view to the detail page. I want to be able to swipe left or right and go to the previous or next item from the collection view as you would in the photos app.
Is there any built-in functionality that allows for easy paging/swiping, or is a programmatic manipulation of the array index the only way to accomplish this task?
I don't know if you are familiar with CocoaPods, but there are plenty that can work for you, for example there is SwiftPhotoGallery, but that just maximizes images and let you swipe right and left as you said.
For the specific functionality you describe I would suggest that in the navigation to the "Detail Page" you sent the whole array too, and just show the index of the item tapped in the collection, your "Detail Page" will be a UICollection as well but with a custom cell that takes the whole space of the screen and with a horizontal flow so you can swipe right and left, if you have this code in your github account or any other repository I'll be willing to help to make my point clearer.

Unable to identify operative event or method in XCode

I need help identifying what piece of code is causing a bug in my app but having a hard time working it out.
So, my app is designed to display a detail screen for any row that is selected in the master table.
I have recently updated my app to use an NSFetchResultsController. The results are what I would expect except for one odd behaviour.
The new behaviour happens when I select a row in the master table, prior to the segue to the detail screen.
The table populates with all the data I would expect. But, on clicking any row in the table (other than the first one), each field in the row is set to the default values that appear in the storyboard.
The segue to the detail screen displays the expected details and the underlying database table is also correct.
I have a segue outlet action on the cell but no other method.
Despite placing breakpoints at various points in the code, I cannot identify which code section is triggering the setting of the row to the storyboard defaults.
I'd appreciate any steer that would help me work this out.
I posted my question as relative newbie to xCode. I've now discovered the profiling tools built into xCode and have been able to identify what's happening in my code with more confidence.

Using a tabbar for controlling the tableview data in iOS without using storyboards

I am building an app which mainly shows a tableview. In this tableview I have some custom table rows. The table rows are filled with data received from the server. I receive multiple kinds of data from the server. I will store it in arrays.
For example, I've got three kinds of arrays. Each is filled with different kinds of data received from the server. See below:
(NSArray*)carList_
(NSArray*)motorcycleList_
(NSArray*)bicycleList_
The actual program that I've got now, only shows the carList in the tableview. Foreach car in carList, there is a table row.
The thing that I've in mind to do is a little bit tricky. I want to add a tabbar at the bottom of the screen with three buttons. When I press the first button, I want the table to be filled with the carList. When I press the second button, I want to fill the table with the motorcycleList. And when I press the third button, I want to fill the table with the bicycleList.
As you can see, I will use the same tableview. I will only refill it with the data I want to see. Is this allowed in iOS? Cause I read something about that the tabbar is for multiple views, and I only want to use it for changing the data in my table. Only the fourth button I've planned for future development will open a new view. If it is not allowed, what is a good alternative do do it? Buttons maybe? I searched the web for what I want to do, but it seems that my idea has never been used before, I think my idea is not allowed in iOS.
At this moment I've a initialViewController (with almost no code cause it is used only to initialize some things of the server. It acts like a splash screen) and I've got a rootViewController which does the works. In the rootViewController I've got my Table with Table rows and it has the different arrays of data which are retrieved by a method that is called when the rootViewController is loaded.
I am programming without Storyboards, because I'd like coding and I want to understand how it works 'underground'. What is a good way to implement the tabbar if it is allowed what I want to do with it? I don't think a standard tab controller will work, because I am working with only one view.
Of course you can use the UITabBar solution. However this might be not very useful and this is not the idea behind the UITabBar. You can instantiate the same TableViewController vor each tab. In this case you can use the same class but you have up to the instances of this class when the user cycles through the tabs. This will be obvisously a waste of memory.
Your descriptions sounds like a UIToolBar with a UISegmetenControl in it might fit your needs better. You can also place it at the bottom of the screen and you will need just one TableViewController for your data.
UISegmentedControl is designed for switching between different data representations. It is also commonly used for switching between table datasources. But it often appears at the top of a view. Take a look at Top Charts tab of App Store app.
Tab bar is designed to present different views for each tab. Here are progress steps to achieve your result:
Use different instances of table view controller for each tab
Configure each instance for displaying one particular array, depending on tab position
Keep arrays in external (outside table view controller) storage, instances should have an access to it
It's better to preload data, while user is examining an active tab. Hence, load data outside of table view controllers, possibly in AppDelegate. Use notifications to update table view when data are available.

drill down UITableView using storyboard in iOS program

I'm trying to develop an iOS app that has drill down UITable View. I got a drill down table view tutorial, but the number of UITableViews is static. What I need is a dynamic one. My requirement is simple. I need to access an FTP Server and get the directory hierarchy (I guess I need to store it in NSDictionary or in an xml file) and display the content in the UITableView. If it is a text file, I need to display it in some view, otherwise I need to display the selected folder's content in the same UITableView, and it goes on till the bottom of the directory hierarchy.
I need to use the storyboard.
I've had to make a something very similar to what your talking about in a previous application I worked on.
In that I created table views inside of table view cells with a button at the top to expand and collapse the view using the cell height.
This worked pretty well but since then I've found the best way to simply programmatically add ui elements to either your table view cells or view.
In both cases I created a management system using parent child architecture to hold your information.
I hope this puts you in the right direction :)

iOS: UI Ideas for moving items between multi-level tableViews

I am building an iOS app that allows the user to browse a tableView, click a cell, then navigate deeper into another tableView using a navigationController.
I have a requirement to be able to move any of those items/cells to another place in the navigation stack. Right now my idea is, once the user selects the cells to move, to display a modal tableView that will allow the user to navigate through the same structure as before, but this time choose the location (by pressing and holding) to place those cells.
Are there any other UI ideas or clever programatic ideas that anyone might have that could be a better solution to this problem?
Perhaps take a look at how Apple's iOS Mail moves email messages between different mailboxes?
This also basically displays a modal view controller, but it flattens the hierarchy, by indenting nested items below their parent objects. You than just select the item that is the destination.
This of course only works if your hierarchy is not too deep, otherwise it's probably best to do it like you outlined it. The only thing I would perhaps recommend doing in addition, is to also have some sort of visual method (button?) to select the destination. A long press by itself might not be intuitive enough.

Resources