I spent a good couple of hours tearing my hair out over a bug in my iPad app the other day. The key problem was that I was getting a crash, without detailed error information. I knew the line in my code that seemed to trigger the issue, a performSegueWithIdentifier call, but the error was an "attempt to insert nil object at 0 on an NSArray, which I wasn't calling. It seemed like the details of the stack trace were obscured behing the performSegueWithIdentifier call.
I was extremely pleased when the following stack overflow post helped me add some code to the AppDelegate that got the strack trace symbolicated and printed out in the debug window
http://stackoverflow.com/questions/7841610/xcode-4-2-debug-doesnt-symbolicate-stack-call
After that I could see that the problem was related to a NavigationItem in one of my controllers that I hadn't hooked up. It was perhaps an understandable slip since as described in one of my previous posts I had to replicate one of my viewcontrollers to support a hierarchy browse since currently viewcontrollers can't segue to an instance of themselves - at least not using the storyboard. So the problem was I had hooked up a navigation item in one controller, but not the replicant ...
I also just renewed by Apple iOS development program. Interesting to discover that they will pull your apps if you don't renew, so I guess I am on the hook for years now. Google's one of payment for android app publication seems increasingly good value by comparison. What's particularly frustrating is that having accidentally upgraded my iPad and iPhone to 5.1 I can no longer deploy apps from Snow Leopard - I must now upgrade to Lion since Apple will not allow me to downgrade to 5.0 on my iOS devices, argh!
Thursday, May 31, 2012
Monday, May 28, 2012
Python SVM on OSX 10.6.8
So I finally got some Python SVM love on OSX 10.6.8 by using the Python bindings for libsvm. However that was after having spent half a day trying to build PyML and Scikit. I had thought these "pure" python projects would be the simpler route to take. I got stuck for a bit installing numpy and other supporting packages, but even having got these working I couldn't get PyML or Scikit to build. The problem was errors like this:
compiling C++ sources
C compiler: c++ -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3
compile options: '-I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -c'
c++: sklearn/svm/src/libsvm/libsvm_template.cpp
llvm-g++-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccpSkuud.out
llvm-g++-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccpSkuud.out
error: Command "c++ -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -c sklearn/svm/src/libsvm/libsvm_template.cpp -o build/temp.macosx-10.3-fat-2.7/sklearn/svm/src/libsvm/libsvm_template.o" failed with exit status 255
and
building 'PyML/containers/ext/_csparsedataset' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c PyML/containers/ext/SparseDataSet_wrap.cpp -o build/temp.macosx-10.3-fat-2.7/PyML/containers/ext/SparseDataSet_wrap.o
In file included from /usr/include/architecture/i386/math.h:626,
from /usr/include/math.h:28,
from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyport.h:312,
from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:58,
from PyML/containers/ext/SparseDataSet_wrap.cpp:149:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
/usr/libexec/gcc/powerpc-apple-darwin10/4.0.1/as: assembler (/usr/bin/../libexec/as/ppc/as or /usr/bin/../local/libexec/as/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/as/x86_64/as for architecture x86_64
/usr/bin/../libexec/as/i386/as for architecture i386
/usr/bin/../libexec/as/arm/as for architecture arm
lipo: can't open input file: /var/tmp//ccyq6iNy.out (No such file or directory)
error: command 'gcc-4.0' failed with exit status 1
I did all the usual searches and played around with gcc settings and so forth, but generally to no joy. I guess I should have posted the above with details to the relevant mailing lists, but having got libsvm to work I just focused on that. I'll come back to this if libsvm hosting becomes an issue for an online deployment ...
Monday, April 30, 2012
Blogging better than local files for data management
So I'm trying to find my notes on this years courses, and having opened lots of other text files recently, my class notes have been pushed off the TextEdit 10 item history, and I can't find it in the usual folders I would expect. Spotlight search always go off and does a complete full text search in the wrong location, AND my whole computer's slowed down because I am trying to push all the 6Gb screen flow files off to my external hard drive, and actually what I am trying to do is go through my 60 chrome tabs and off load the stuff that I don't want to lose when I next have to reboot it to run Google Hangouts, so it seems ironically that blogging is easier for this kind of data management than files on my hard disk. If only my file manager let me type in file names and I got autocomplete like I do in my browser.
Anyway here is a good resource I found on learning github:
http://learn.github.com/p/tagging.html
I also keep meaning to try out this approach of having git push to multiple repositories, so that a heroku push would also push to github:
http://stackoverflow.com/questions/165092/can-i-push-to-more-than-one-repository-in-a-single-command-in-git
I'm trying to pull all my github related resources together as I'm going to make github use a required part of all my future online CS classes. I have gotten a bit sick of email attachments and dropbox.
And a random note, I managed to fix my printer by using a damp cloth:
http://h30434.www3.hp.com/t5/Other-Printing-Questions/Officejet-Pro-8500-quot-out-of-paper-quot-error-message/m-p/186605#M11353
Anyway here is a good resource I found on learning github:
http://learn.github.com/p/tagging.html
I also keep meaning to try out this approach of having git push to multiple repositories, so that a heroku push would also push to github:
http://stackoverflow.com/questions/165092/can-i-push-to-more-than-one-repository-in-a-single-command-in-git
I'm trying to pull all my github related resources together as I'm going to make github use a required part of all my future online CS classes. I have gotten a bit sick of email attachments and dropbox.
And a random note, I managed to fix my printer by using a damp cloth:
http://h30434.www3.hp.com/t5/Other-Printing-Questions/Officejet-Pro-8500-quot-out-of-paper-quot-error-message/m-p/186605#M11353
Monday, April 23, 2012
iOS Storyboards tying me in knots
So I was wondering whether would it make sense to have a reciprocal segue when navigating down a hierarchy of categories of unknown depth in ios5? I was thinking that the iOS navigation controller should provide the back button stuff etc., but it seems like if I was setting this up in a storyboard then I need to keep on seguing over and over again to the same controller displaying the current list of categories ...After some help from iphonedev on irc.freenode.net I wasn't able to create a segue from one viewcontroller to itself, but I was able to make a seque to a clone of that view controller (Option Key drag to copy out of the left hand list view of items, thanks Psy) and I got the convoluted hook up pictured here. Seems remarkably unDRY, but it works and I can now navigate up and down the category hierarchy with the navigation controller handling the back button to get back up again as necessary.
Friday, April 13, 2012
Eclipse Android Development Toolkit (ADT)
So I'm grading like 30 android phone and tablet projects for my mobile programming class, and there are things I keep encountering through the Eclipse Android Development Toolkit (ADT). Some good, some bad.
In particular there's this issue of the various android emulators and devices getting detached from the ADT, which means you can't deploy. You then have to do this convoluted thing of going to the DDMS perspective in Eclipse, and clicking on the extra commands arrow in the device window, and then selecting "reset adb" and then gettting this confusing error message "Adb failed to restart! Make sure the plugin in properly configured", which you can't copy and paste and you have to ignore and then your devices/emulators connect back up.
This happens pretty regularly for me on OSX, and has been happening since at least Android 1.5 I think. There are a few google hits on this, but not much, and this is likely in part that the error message can't be copied and pasted, and most experienced coders simply click "OK" and move on, but it's very confusing for newbies.
You'd have thought that a big company like Google could get this fixed up. Maybe no one cares enough - maybe it's only happening for a few of us. Maybe I'd have to bring it up at Google I/O or something to get it fixed.
In general though any other kind of error that can be copied and pasted is usually easily solved via StackOverflow, e.g. when the ADT tells me that I can't install an app due to an existing one with the same signature and I have to type "adb uninstall whatever" in a shell and then I get this from the shell:
unknownc8bcc8da38b2:platform-tools samueljoseph$ ./adb uninstall edu.hpu.csci4702
- waiting for device -
error: more than one device and emulator
In particular there's this issue of the various android emulators and devices getting detached from the ADT, which means you can't deploy. You then have to do this convoluted thing of going to the DDMS perspective in Eclipse, and clicking on the extra commands arrow in the device window, and then selecting "reset adb" and then gettting this confusing error message "Adb failed to restart! Make sure the plugin in properly configured", which you can't copy and paste and you have to ignore and then your devices/emulators connect back up.
This happens pretty regularly for me on OSX, and has been happening since at least Android 1.5 I think. There are a few google hits on this, but not much, and this is likely in part that the error message can't be copied and pasted, and most experienced coders simply click "OK" and move on, but it's very confusing for newbies.
You'd have thought that a big company like Google could get this fixed up. Maybe no one cares enough - maybe it's only happening for a few of us. Maybe I'd have to bring it up at Google I/O or something to get it fixed.
In general though any other kind of error that can be copied and pasted is usually easily solved via StackOverflow, e.g. when the ADT tells me that I can't install an app due to an existing one with the same signature and I have to type "adb uninstall whatever" in a shell and then I get this from the shell:
unknownc8bcc8da38b2:platform-tools samueljoseph$ ./adb uninstall edu.hpu.csci4702
- waiting for device -
error: more than one device and emulator
So I google the error message in quotes and I go to the stackoverflow hit since that's usually the best way to make progress:
and I see how to uninstall from a particular device. So that all kinds of work, but I wonder why these IDEs couldn't be a little more user-friendly - I have similar issues with XCode. With both XCode and Eclipse ADT I feel like a lot of disparate tools have been bundled together and are not quite working properly. Maybe that's just the nature of things ...
Monday, April 2, 2012
Customizing Google Sites to Individual Users
Ever since Google Groups discontinued support for pages and files I've been running my classes on Google Sites, at least for hosting content.
The sign in link for individual users in Google sites is very carefully hidden at the bottom of the screen making it seem like the emphasis is on content hosting for all rather than on customizing content for individual users, but that is exactly what I'd like to do in order to, for example, show students in my classes which assignments they've completed etc.
It seems like there should be some way to do this, but my searches so far have proved inconclusive, as I keep searching and not quite coming up with anything concrete. It seems like Google App Scripts should help, but I'll have to look again once the semester has finished:
https://developers.google.com/apps-script/articles
The sign in link for individual users in Google sites is very carefully hidden at the bottom of the screen making it seem like the emphasis is on content hosting for all rather than on customizing content for individual users, but that is exactly what I'd like to do in order to, for example, show students in my classes which assignments they've completed etc.
It seems like there should be some way to do this, but my searches so far have proved inconclusive, as I keep searching and not quite coming up with anything concrete. It seems like Google App Scripts should help, but I'll have to look again once the semester has finished:
https://developers.google.com/apps-script/articles
XCode StoryBoarding and SplitViews
So I burnt a lot of time last week trying to get XCode Storyboards working nicely with UISPlitViews on the iPad. One of the more helpful resources was this one:
http://www.techotopia.com/index.php/Using_Xcode_Storyboarding_(iPhone_iOS_5)
which I found by searching Google for "programmatically trigger segue". My previous search for "splitviewcontroller segue" was less helpful, turning up short, not really relevant StackOverflow posts.
I also skimmed the following tutorial, but wasn't able to pull the information I wanted fast enough:
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2
Ultimately I got it all working, and I think the biggest roadblock was the idea that the segues still needed to be created in the StoryBoard interface, but that I would trigger them and catch them programmatically. Given that I wanted different segues to take place depending on whether the user clicked a table cell in the master view, or the associated detail disclosure button. The trick was to have segues in the Storyboard running from the master view to two other UI views, one for each of the possible segues, but then adjusting the segue type to specify the detail view to ensure that the right part of the splitviewcontroller was updated.
Particularly after some not too disimilar trials and tribulations with Android fragments it makes me wonder if there isn't some way to make mobile development a little less hazardous ...
Of course having got that working there was still the unpleasantly convoluted issue of trying to make the test in a UITableViewCell wordwrap to keep me entertained:
http://stackoverflow.com/questions/2906090/how-to-make-text-in-a-uitableviewcell-wordwrap
http://stackoverflow.com/questions/494562/setting-custom-uitableviewcells-height
http://the-lost-beauty.blogspot.co.uk/2009/11/multi-line-uitableviewcell-using.html
I kind of hacked a solution there. It seems remarkable that there isn't a dynamic sizing solution that doesn't require hacking at code - maybe I just haven't found it yet.
I think I was also also tripped up by the detailTextLabel not being visible:
http://stackoverflow.com/questions/5190648/why-is-detailtextlabel-not-visible
All my attempts to set a nice background gradient for some elements in the table view failed :-( The top three StackOverflow hits for my google search on "CAGradientLayer UILabel" seemed promising, but I couldn't get it to work. I did however manage to get something to appear by creating a dummy transparent PNG of the right size and then was able to dynamically create a UILabel with a number on it.
http://www.techotopia.com/index.php/Using_Xcode_Storyboarding_(iPhone_iOS_5)
which I found by searching Google for "programmatically trigger segue". My previous search for "splitviewcontroller segue" was less helpful, turning up short, not really relevant StackOverflow posts.
I also skimmed the following tutorial, but wasn't able to pull the information I wanted fast enough:
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2
Ultimately I got it all working, and I think the biggest roadblock was the idea that the segues still needed to be created in the StoryBoard interface, but that I would trigger them and catch them programmatically. Given that I wanted different segues to take place depending on whether the user clicked a table cell in the master view, or the associated detail disclosure button. The trick was to have segues in the Storyboard running from the master view to two other UI views, one for each of the possible segues, but then adjusting the segue type to specify the detail view to ensure that the right part of the splitviewcontroller was updated.Particularly after some not too disimilar trials and tribulations with Android fragments it makes me wonder if there isn't some way to make mobile development a little less hazardous ...
Of course having got that working there was still the unpleasantly convoluted issue of trying to make the test in a UITableViewCell wordwrap to keep me entertained:
http://stackoverflow.com/questions/2906090/how-to-make-text-in-a-uitableviewcell-wordwrap
http://stackoverflow.com/questions/494562/setting-custom-uitableviewcells-height
http://the-lost-beauty.blogspot.co.uk/2009/11/multi-line-uitableviewcell-using.html
I kind of hacked a solution there. It seems remarkable that there isn't a dynamic sizing solution that doesn't require hacking at code - maybe I just haven't found it yet.
I think I was also also tripped up by the detailTextLabel not being visible:
http://stackoverflow.com/questions/5190648/why-is-detailtextlabel-not-visible
All my attempts to set a nice background gradient for some elements in the table view failed :-( The top three StackOverflow hits for my google search on "CAGradientLayer UILabel" seemed promising, but I couldn't get it to work. I did however manage to get something to appear by creating a dummy transparent PNG of the right size and then was able to dynamically create a UILabel with a number on it.
Subscribe to:
Posts (Atom)

