Hard time debugging Local Variable in XCode - objective-c

I'm having a hard-time debugging a local variable. I'm running gcc 4.2, XCode 3.2.4, base SDK Mac OS 10.5, and Objective-C++ in Debug-Mode.
Here's the issue. I'm working on trying to understand some code and it goes like this:
#define MAX4D 500
...
NSMutableArray *viewerPix[ MAX4D ];
When I hover over it during debug (pause on the line before and after) I get this
Unable to access variable "viewerPix"
Unable to access variable "viewerPix"
Unable to access variable "viewerPix"
...
repeated until I kill the application. What would cause this? I've tried setting it to a lower number... but to no avail. Even after I actually set the C-Array:
viewerPix[0] = [[NSMutableArray alloc] initWithCapacity:0];
I still get the same repeated error message.
However, if I don't mouse-over the value (or debug) it "appears" to run fine, even doing stuff like:
[viewerPix[0] addObject: dcmPix];
if( [viewerPix[0] count] != [loadList count])...
but if I debug after those steps, it crashes just like before. Here are my build settings:
STRIPFLAGS =
ALTERNATE_GROUP = $(INSTALL_GROUP)
ALTERNATE_OWNER = $(INSTALL_OWNER)
ALTERNATE_MODE = $(INSTALL_MODE_FLAG)
ALTERNATE_PERMISSIONS_FILES =
DEPLOYMENT_LOCATION = NO
DEPLOYMENT_POSTPROCESSING = NO
INSTALL_GROUP = $(GROUP)
INSTALL_OWNER = $(USER)
INSTALL_MODE_FLAG = u+w,go-w,a+rX
DSTROOT = /tmp/$(PROJECT_NAME).dst
INSTALL_PATH = $(HOME)/Applications
SKIP_INSTALL = NO
COPY_PHASE_STRIP = NO
STRIP_INSTALLED_PRODUCT =
STRIP_STYLE = debugging
SEPARATE_STRIP = NO
GCC_FAST_OBJC_DISPATCH = YES
GCC_AUTO_VECTORIZATION = NO
GCC_OBJC_CALL_CXX_CDTORS = YES
GCC_ENABLE_SSE3_EXTENSIONS = NO
GCC_ENABLE_SSE41_EXTENSIONS = NO
GCC_ENABLE_SSE42_EXTENSIONS = NO
GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = NO
GCC_STRICT_ALIASING = NO
GCC_FEEDBACK_DIRECTED_OPTIMIZATION = Off
GCC_ENABLE_FIX_AND_CONTINUE = NO
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
GCC_DYNAMIC_NO_PIC = NO
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
GCC_MODEL_TUNING = G5
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
GCC_ENABLE_KERNEL_DEVELOPMENT = NO
GCC_DEBUGGING_SYMBOLS = default
GCC_REUSE_STRINGS = YES
GCC_NO_COMMON_BLOCKS = NO
GCC_ENABLE_OBJC_GC = unsupported
GCC_OPTIMIZATION_LEVEL = 0
GCC_FAST_MATH = NO
GCC_ENABLE_SYMBOL_SEPARATION = YES
GCC_THREADSAFE_STATICS = YES
GCC_SYMBOLS_PRIVATE_EXTERN = NO
GCC_UNROLL_LOOPS = NO
GCC_MODEL_PPC64 = NO
I don't know what else to say. Let me know what more information is needed, because I'm at a loss. There's also no 'build' tab when I get-info on the .mm file. Just General, Target, Comments (some helps I checked said to remove file-specific tags).
Should I initialize that c-array to nil? I can't just do.. array[500] = {nil}; right? that's C#?
I was using LLVM and Clang 1.5, but I switched to GCC 4.2 since I wasn't getting any local symbols. Am I missing something??

If the optimizer is on, that can effectively eliminate local variables.
However, why a C array of mutable ObjC arrays? That seems odd.

check Product->Scheme->Edit Scheme->Run xxx, Build Configuration is Debug, if that is Release happened you see.

Related

Changes in lua language cause error in ai script

When I run script in game, I got an error message like this:
.\AI\haick.lua:104: bad argument #1 to 'find' (string expected, got nill)
local haick = {}
haick.type = type
haick.tostring = tostring
haick.require = require
haick.error = error
haick.getmetatable = getmetatable
haick.setmetatable = setmetatable
haick.ipairs = ipairs
haick.rawset = rawset
haick.pcall = pcall
haick.len = string.len
haick.sub = string.sub
haick.find = string.find
haick.seed = math.randomseed
haick.max = math.max
haick.abs = math.abs
haick.open = io.open
haick.rename = os.rename
haick.remove = os.remove
haick.date = os.date
haick.exit = os.exit
haick.time = GetTick
haick.actors = GetActors
haick.var = GetV
--> General > Seeding Random:
haick.seed(haick.time())
--> General > Finding Script Location:
local scriptLocation = haick.sub(_REQUIREDNAME, 1, haick.find(_REQUIREDNAME,'/[^\/:*?"<>|]+$'))
Last line (104 in file) causes error and I don`t know how to fix it.
There are links to .lua files below:
https://drive.google.com/file/d/1F90v-h4VjDb0rZUCUETY9684PPGw7IVG/view?usp=sharing
https://drive.google.com/file/d/1fi_wmM3rg7Ov33yM1uo7F_7b-bMPI-Ye/view?usp=sharing
Help, pls!
When you use a function in Lua, you are expected to pass valid arguments for the function.
To use a variable, you must first define it, _REQUIREDNAME in this case is not available, haick.lua file is incomplete. The fault is of the author of the file.
Lua has a very useful reference you can use if you need help, see here

How to access file info programmatically on Mac?

Setup:
I have a bunch of audio files on my new Mac (Yosemite). When I right click on any file and do "Get Info", it gives me nice detailed info about that song under "More Info" tag, e.g.
Objective:
I need to write a program where I can list, something like this for all songs in a directory:
Album, Title, Year Recorded
.
.
.
Problem:
I have no idea how to do this. I am totally new to Mac and Objective-C/Swift (Objective-C or Swift is what I will have to use to write this program I guess??)
Is there an API where I can access this file info programmatically? And is there any other language which I can use to write this sort of program? Something which I already know, like Java, Python, etc.?
I don't have any code as of now to show 'What I have tried so far', since I am still searching for the starting point. Any pointers would be much appreciated.
As you've noticed, the mdls command can provide this metadata. You should not try to parse that. Instead, you can use the same APIs that it is built on.
You need to obtain an NSURL for a file of interest. Then, you can obtain a dictionary of its metadata attributes like so:
MDItemRef item = MDItemCreateWithURL(NULL, (__bridge CFURLRef)url);
NSArray* names = #[ (__bridge NSString*)kMDItemAlbum, /* ... */ ];
NSDictionary* dictionary = CFBridgingRelease(MDItemCopyAttributes(item, (__bridge CFArrayRef)names));
CFRelease(item);
Now, dictionary contains the desired attributes.
So, I have found one way to do this.
Mac does provide a utility called mdls, which lists file metadata. So if I do the mdls on my about example file, I get this:
myuser00m:Hindi myuser$ mdls Pani\ Da\ Rang.mp3
kMDItemAlbum = "Vicky Donor"
kMDItemAlternateNames = (
"/Users/myuser/Documents/My Stuff/Music/Hindi/Pani Da Rang.mp3"
)
kMDItemAudioBitRate = 165000
kMDItemAudioChannelCount = 2
kMDItemAudioEncodingApplication = "Eac * Lame"
kMDItemAudioSampleRate = 44100
kMDItemAuthors = (
"Ayushmann Khurrana"
)
kMDItemComposer = "Music: Abhishek - Akshay"
kMDItemContentCreationDate = 2015-06-16 04:42:30 +0000
kMDItemContentModificationDate = 2015-06-16 04:42:30 +0000
kMDItemContentType = "public.mp3"
kMDItemContentTypeTree = (
"public.mp3",
"public.audio",
"public.audiovisual-content",
"public.data",
"public.item",
"public.content"
)
kMDItemCopyright = "www.Songs.PK"
kMDItemDateAdded = 2015-07-26 19:52:49 +0000
kMDItemDisplayName = "Pani Da Rang"
kMDItemDurationSeconds = 240.8489795918368
kMDItemFSContentChangeDate = 2015-06-16 04:42:30 +0000
kMDItemFSCreationDate = 2015-06-16 04:42:30 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "Pani Da Rang.mp3"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 784317889
kMDItemFSOwnerUserID = 376797083
kMDItemFSSize = 5826388
kMDItemFSTypeCode = ""
kMDItemKind = "MP3 audio"
kMDItemLogicalSize = 5826388
kMDItemLyricist = "www.Songs.PK"
kMDItemMediaTypes = (
Sound
)
kMDItemMusicalGenre = "Bollywood"
kMDItemPhysicalSize = 5828608
kMDItemRecordingYear = 2012
kMDItemTitle = "Pani Da Rang"
kMDItemTotalBitRate = 165000
myuser00m:Hindi myuser$
Now I need to write some code to parse this and extract fields of interest.
Obviously, it is not that cool solution, but until I find something better, this will do. I will update my answer once I find something better.

How to reach NSDictionary properties that have a class?

I've created an NSMutableArray with a class "Adealer" for it's objects. In my "listVC" I populate all the properties (as shown below) within a loop, where the "Adealer" class is used to create objects.
I then transferred one object from that array via a segue to my "detailsVC". Here I first import Adealer class and when I call this in my "detailsVC";
NSLog(#"restGPSTransfer (NSDictionary) class = %#, content is = %#",[restGPSTransfer class],[restGPSTransfer description]);
I get this;
restGPSTransfer (NSDictionary) class = Adealer, content is =
theDealer object and it's properties:
dealerID = 7
dealerName = Uppsala Centrum Test
dealerAdressStreet = Dragarbrunnsgatan 55
dealerAdressZip = 75320
dealerAdressCity = Uppsala
dealerTel =
dealerMail =
dealerWeb = www.uppsala.se
dealerLogo =
dealerImages =
dealerText = Uppsala centrum
dealerProducts =
dealerLongitude = 17.63893
dealerLatitude = 59.85856
dealerDistance = (null) // This is ok
dealerDistance2 = 8586398.000000
So far so god, BUT I can't reach the above properties in a simple call like this in the "detailsVC" (?!);
self.labelRestName.text = [restGPSTransfer objectForKey:#"dealerName"];
...it crashes with the error: "-[Adealer objectForKey:]: unrecognized selector sent to instance 0x8a92db0" (then termination with InvalidArgumentExeption...)
What have I missed?
Much more detail can be found in my question here (which I still got no answers to!);
How do I get out data from my NSDirectory (not just a property typo)?
Thank's for any help :-)
It looks like memory issue,
Are you using ARC?
Could you add your dictionary allocation code?

Zend Framework: Multidb fails to initialize

This used to work but after some modifications by the other programmers it just fails to work. I have this code on my Bootstrap:
protected function _initDatabase ()
{
$resource = $this->getPluginResource('multidb');
$resource->init();
Zend_Registry::set('gtap', $resource->getDb('gtap'));
Zend_Registry::set('phpbb', $resource->getDb('phpbb'));
}
Upon loading, this error shows up:
Fatal error: Call to a member function init() on a non-object in
/var/www/gamebowl3/application/Bootstrap.php on line 105
My php.ini has this entry on tis include_path:
.:/usr/share/php:/etc/apache2/libraries
and the i can see that multidb.php is located in:
/etc/apache2/librarties/Zend/Application/Resource
Can somebody tell me what causes the error? Thanks!
I just found out that the problem is in application.ini. Added a newly-introduced setting to the usual set of configs. Here it is:
;Gtap Database
resources.multidb.gtap.adapter = "PDO_MYSQL"
resources.multidb.gtap.host = "localhost"
resources.multidb.gtap.username = "root"
resources.multidb.gtap.password = "letmein1"
resources.multidb.gtap.dbname = "gtap"
resources.multidb.gtap.isDefaultTableAdapter = true
resources.multidb.gtap.default = true
;Forum Database
resources.multidb.phpbb.adapter = "PDO_MYSQL"
resources.multidb.phpbb.host = "localhost"
resources.multidb.phpbb.username = "root"
resources.multidb.phpbb.password = "letmein1"
resources.multidb.phpbb.dbname = "phpbb"
resources.multidb.phpbb.isDefaultTableAdapter = false
Also, make sure you have the latest Zend Framework Library and add it to PHP's include path. That should fix everything up.

boost::asio and make_shared does not work?

I seem to be able to use boost::make_shared everywhere except with boost asio?
example: _ioService = boost::shared_ptr<io_service>(new io_service)
if I turn this into: _ioService = boost::make_shared<io_service>()
I get all kinds of errors?
Same problem if I take:
_acceptor = boost::shared_ptr<tcp::acceptor>(new tcp::acceptor(*_ioService));
and turn it into this:
_acceptor = boost::make_shared<tcp::acceptor>(*_ioService);
As boost::asio::tcp::acceptor takes a boost::asio::io_service by non-const reference you need to change:
_acceptor = boost::make_shared<tcp::acceptor>(*_ioService);
to:
_acceptor = boost::make_shared<tcp::acceptor>(boost::ref(*_ioService));