"No appropriate method" error generated when calling new function using class-defined object - oop

I defined a class called "FilterCriteria" which has a bunch of function .m files (getAMask, getBMask, etc.) associated with it. When I create the FilterCriteria object and call the functions using it, I don't have any problems. However, recently I added another function (which, on a side note, is almost identical to another function that still works), and Matlab returns the error, "No appropriate method, property, or field getHMask for class FilterCriteria."
I've searched online for this problem, but I can't find anything. The file getHMask.m is definitely in the correct folder, so I don't understand why Matlab seems to have such a problem finding it.
Here's getHMask.m's header:
function mask = getHMask(object, quadrant, channel)
Any help would be greatly appreciated. Thanks in advance.

1) A mistake I make sometimes is not saving the file with the correct name. Make sure capital letters are in the right places etc!
2) Another layer of error checking here... You can call methods('object here') (see here) and make sure it lists the method (function) that you are trying to add to it. If it doesn't show up here you should check into the implementation of the method and make sure it's correctly being added to the class you're using for your object.

I had the same problem that's kind of suggested by Ben's bullet #2 and it was driving me crazy. Turns out MatLab wasn't loading the latest version of my class's m-file. I vaguely remembered it gave me a warning earlier about that, because there were old instances of the class in the workspace and to keep from invalidating them it said it wouldn't update the class until I cleared the workspace...
So if that's the problem, restarting MatLab will work, or you can just enter >> clear

Related

AS2 AttachMovie from loaded swf movie

i'm facing one problem about attaching movieclip from loaded movie, so basically we have a Map
Map.loadMovie("SimpleMap.swf");
in this map there's a npc dialogue with its name "Dialogue1" I want to attach it to the client. It should be basically something like
_root.attachMovie("Map.Dialogue1", "dialogue", _root.getNextHighestDepth());
but it seems I can't get it to work. Anyone can help?
Note: Also I want to attach the movieclip to the client instead of the map, else I would use Map.attachMovie
it's been a while since I wrote any Actionscript 2 stuff, but have you tried removing the quotes around Map.Dialogue1 ? - If I remember correctly passing a string would make Flash look for the symbol in the library, not from the global or current scope...
_root.attachMovie(Map.Dialogue1, "dialogue", _root.getNextHighestDepth());
If you want you can import mx.core.UIObject and then use the method _root.createObject() (or if it is O-O use createClassObject()).
It is going to attach the "npc dialog" as an object... you need to specify the linkage name and give the instance a name. So for example if you called the dialog "npc_dialog" in the library then use:
_root.createObject("npc_dialog", "my_npc", _root.getNextHighestDepth());
Here is something else you can try... go to the library and drag a instance of the movie onto the stage somewhere where it will not be seen, like for instance on the next key frame or off the stage then try to run attachMovie().
What happens is flash will compile the clip in the most efficient way possible so if it sees you imported a package but did not use it then it will ignore this class in the compiled clip... so when you go to run and it tries to attach the movie it can't find it.

Why is the value of variable different when using CCLog and using print in debug mode?

The strengthbar in my game doesn't work well after playing at least once of the level. So I wrote a method using CCLog to log out some variables and call this method in update: method. And I also set a breakpoint, when this problem appears it gets into debug mode of Xcode, then I use print to check the variables. However it appears that the values are different between using CCLog and using print command. Here's a screenshot that explains everything.
Here is my screenshot:
Does it have something to do with Multithreads(which I know nothing about)? I've checked the declaration of each logged variables, to make sure they're not declared several times using the same name.
OK, problem is solved.
When I wrote some delegate I used "Strong" which causes some retain cycles. Now I changed them all to Weak, and also changed the deployment settings to iOS 5 (or above).
The reason that the values of the variable are different is because in CCLog, the value belongs to the new scene, however there're more than one scene at the same time receiving my touches because of the retain cycles. Nothing wrong about XCode or Cocos2d, or CCBReader :-p
Hope this answer would help others. And many thanks to #Cy-4AH.
Because it was changed after it was printed. In the breakpoint you are lookng at new value.

xCode: Accessing properties of an object via console

Is it possible to access the properties of objects in xCode console?
If I try the following I get an error that he property doesn't exist.
po someObject.someprop
If I don't breakpoint the code and run the app it works fine so I know someObject.someprop exists. I don't think I have the grasp on xCode console yet? What I loved about Flex/Flash development is that I could set a break point and in the console window or variables view I could traverse every structure down to the ends of the earth.
I could see SomeDicionary[key].someArray[1].someObject.prop and it would show me the value. Is this not possible in xCode console or is there a trick to get to it?
You'll actually have to use the bracket syntax notation:
po [someObject someprop]
The debugger is sometimes very finnicky about syntax. This is filled with all sorts of helpful tips for debugging in XCode.
Just a side note, variables/properties declared in the implementation file (*.m) instead of the header file (*.h) can sometimes be invisible to the debugger variable list display depending on if the breakpoint is in that class's code, because of scope. Not necessarily required here, but useful to know seeing as how it is kind of relevant.

create a new object

I want to create a new object so as to instantiate and use it several times;
For example, if I want to create an object that has a label and a button inside, how do I? I created a new NSObject but inside it has nothing, then how do I make everything from scratch since there was a viewDidLoad for example (obviously, since it has a view)?
thanks!
Your questions lead me to think that you're really just starting out. There's nothing wrong with that, but rather than trying to summarize several megabytes of documentation in a few paragraphs, I'm just going to point you to the iOS Starting Point. I think that you're just trying to create a container that can hold other UI components? If so, use a UIView for that. However, don't jump in and try to get something specific done without first reading through some of the Getting Started documents -- you'll just end up back here, and we'll just point you back to the docs. You might like the Your First iOS Application guide, as that lets you get your feet wet but explains things along the way.

Problem with QSqlTableModel -- no automatic updates

After setting up a table model in Qt 4.4 like this:
QSqlTableModel *sqlmodel = new QSqlTableModel();
sqlmodel->setTable("Names");
sqlmodel->setEditStrategy(QSqlTableModel::OnFieldChange);
sqlmodel->select();
sqlmodel->removeColumn(0);
tableView->setModel(sqlmodel);
tableView->show();
the content is displayed properly, but editing is not possible, error:
QSqlQuery::value: not positioned on a valid record
I can confirm that the bug exists exactly as you report it, in Qt 4.5.1, AND that the documentation, e.g. here, still gives a wrong example (i.e. one including the removeColumn call).
As a work-around I've tried to write a slot connected to the beforeUpdate signal, with the idea of checking what's wrong with the QSqlRecord that's about to be updated in the DB and possibly fixing it, but I can't get that to work -- any calls to methods of that record parameter are crashing my toy-app with a BusError.
So I've given up on that idea and switched to what's no doubt the right way to do it (visibility should be determined by the view, not by the model, right?-): lose the removeColumn and in lieu of it call tableView->setColumnHidden(0, true) instead. This way the IDs are hidden and everything works.
So I think we can confirm there's a documentation error and open an issue about it in the Qt tracker, so it can be fixed in the next round of docs, right?
It seems that the cause of this was in line
sqlmodel->removeColumn(0);
After commenting it out, everything work perfectly.
Thus, I'll have to find another way not to show ID's in the table ;-)
EDIT
I've said "it seems", because in the example from "Foundations of Qt development" Johan Thelin also removed the first column. So, it would be nice if someone else also tries this and reports results.
I use Qt 4.6.1 in PyQt and the problem is still here. Removing "removeColumn(0)" solves the issue.