Unable to identify operative event or method in XCode - ios

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.

Related

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

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

NSFetchedResultsController saving data but UITableView not configuring cell

When returning from a ViewController where I add and save an NSManagedObject, the TableView inserts a blank cell where the new cell should be. If I back out from the tableview screen and go back, it reloads and configures everything properly.
So what I know from this is that the data is being properly saved to the store, I know the FRC delegate operations are all being called (.Insert, for instance), and I actually can see via breakpoints that my "configureCell" method is being called and is passing back a fully configured cell. The tableview is just putting in a blank one instead.
I can post code if you'd like, but I was just curious if this description rang any bells for anyone? I've been researching this problem off and on for weeks but haven't really found anything similar.
For troubleshooting purposes I:
took my custom UITableViewCell out of the mix and just had the tableview configure a generic cell... didn't help.
created a stripped-down version of the app flow in another project, including core data, FRC, custom tableview cell, etc... this actually DOESN'T display the same behavior. I've compared the two projects side by side and can't determine any meaningful difference (other than the data itself that's being displayed).
I've even gone so far as to insert a delay between the context.save() operation and dismissing the VC where I create the object, just to see if it's some sort of race condition between when the object is created and when the table configures the cell. Needless to say, that did nothing.
Is this a bug anyone else has encountered? Anyone seen this behavior before?
Thanks in advance, sorry for the wall but this is something that Google, various subreddits, and so far StackOverflow has not been able to help me with.
Well after rephrasing my question I found this from back in May.
New table view cell shows as a blank cell
No solution there, but I reached out to him via twitter and his suggestion worked. Switching my size class back to any/any seems to have solved the problem, which means this might be an autolayout bug. It needs more testing but I think I've done everything that would demonstrate the issue and I think it's resolved.

WatchKit Table flickering when updated

I am currently working on a watchkit app and ran into a problem with a flickering table.
The situation is as follows: With the storyboard tool, I created a table containing two row types.
The concept is, that when the data for the table is being downloaded, there is only one row of the first type which will use the whole space to indicate, that data is being downloaded. When the data arrives the second row type is used to display the data.
The problem is, that the table is somehow flickering, while it is being updated with the data. I was able to fix this problem by removing the download indication message und using only the one row type for data.
My question is, if someone did run into a similar problem or if there is any better way/pattern to display this kind of information messages, which show the user whats going on when he is using the app.
The WatchKit Table will flicker when reloading when a visible cell is different size than the other cells. Make sure they are all the same height and width and you will not have a flicker.
The way I did it was to put a group above my table that took up the entire screen with a loading animation inside it. I then hide/show the groups as needed.

UIScrollView multiple page confusion

So I have an existing app I'm working on for a friend...
and let's say I double click on animals_real and I get this screen...
Basically all I want to do is create a back button back to the home page on the animals_real page and all the other ones like it(body_parts_real, cleaning_real, etc.) but for whatever reason I can't find the xib file or the code for it and I'm not entirely sure what file it would be in. Also, since I am fairly new I'm not entirely sure how to implement the back button. Any help is greatly appreciated.
----------------------------------EDIT 1------------------------------------------
The main page works under ViewControllerForIphone.xib and the settings page is under SettingViewControllerIphone.xib. This led me to believe that the other pages would be under the SubPECSViewController_iPhone.xib. However, if I go in and edit that it doesn't change anything when I run the simulator. So, basically I have been trying to understand UIScrollView better and how it works but I am kind of just stuck.
Welcome to iOS. Other commenters will point out that you should start here at the UICollectionViewDelegate Reference (which you can also get to through Xcode (shift+command+0)
Basically, a uicollection view populates itself based on some array of data.Look here to see what's going on
(void)insertItemsAtIndexPaths:(NSArray *)indexPaths
When you tap on animals, this method is called:
– collectionView:didSelectItemAtIndexPath:
Some logic happens here, and I'm presuming you load the collectionview from yet another array.
To solve your original problem of a "back button," you might simply want to reload the viewcontroller's original datasource or possibly "pop" back up the navigation stack. Again, without seeing at least part of the code, there's very little we can do except speculate :)

When I transfer from my master view to my detail view after adding a new item, my detail view is empty

I'm making a sample app to learn iOS dev, and I have the app create default items to populate the tableview originally, and you can add further ones as well.
If I tap on the default ones (well, there's only one) and segue to the detail view it shows all the details (Name, Location and Date) as intended. But if I add a new one, it comes up with those fields being Empty.
I can't figure out why. I have seemingly all the view refreshing methods set, and it should be setting the detail view's data object which then feeds the labels.
Could anyone help? I'd supply further code if requested, I just don't know what to supply now as I'm not sure exactly where the problem is. It's a rather simple app, though.
Project available here: http://cl.ly/3N0o272M3y1K
Ok this took a bit longer than planned - but it is a good way to learn.
I have attached the project in a zip file.
The code is a bit different then what you posted, but if you compare them side by side, you will see how they are planned and build differently.
It shows the Segue working within the Storyboard.
There where 2 big problems with your project outside of your misuses of the methods.
You need something like Core Data if you want your data to be persistant. In the example I have given you I have used Plist, this will do the trick, but is not persistant in this case.
Also your detailViewController had no labels for the text to appear, so you will need to look into Custom Cells for that - to match your design.
Good Luck and I hope this is useful:-)
Updated Project

Resources