I'm interested in the way I am retaining my properties and the aspects of memory management. This is for a simple application that edits the information of a class that is stored in a table. There are 3 ViewControllers.
A list view (list all classes)
a detail view of the selected item
(lists properties of selected class)
an edit view...
I have a loop using the for (NSObject *obj in someArray) { } syntax. Is there an easy way to tell if I'm on the last iteration of the loop (ie. without having to use [someArray count])
...
My application seems to have acquired a slightly odd behaviour when it terminates. When I close a the main window using the standard little red button in the top left the application crashes. I haven't made any changes to the application that would obviously cause this problem. I'm struggling to debug the problem because the application ...
What conventions are people here following for naming of instance variables and method arguments - particularly when method arguments are used to set ivars (instance variables)?
In C++ I used to use the m_ prefix for ivars a lot. In C# I followed the convention of disambiguating purely by use of this. for ivars. I've since adopted the e...
I want to be able to debug C structures without having to explicitly type every property that they consist of.
i.e. I want to be able to do something like this:
CGPoint cgPoint = CGPointMake(0,0);
NSLog(@"%@",cgPoint);
Obviously the '%@' won't work, hence the question.
...
hi Guys,
I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the FUTURE...
I used to use doxygen lot for C++, and really like the ability to document function and method arguments inline using ///< , or variations. Conversely I really dislike having to repeat arguments in the comments when not using the inline style (as most over code doc systems only support).
So recently I've been setting up doxygen with my ...
Objective-C 2.0 has some new enhancements:
garbage collection
fast enumeration: for..in
properties
thread synchronization: @synchronized(self)
@try/@catch/@finally/@throw exception
handling
I'm interested in using Objective-C 2.0 as a language to program portable code across multiple operating system platforms - while avoiding framew...
I have a project that compiles with some warnings. It's an iPhone project that uses some methods on NSDate, that are seemingly not the headers of the iPhone SDK, but work flawlessly none the less. When I call these methods I get warnings like:
So how do I silence the warnings permanently, in order to tell XCode "it's OK, really."
O...
Hello,
I have a problem which I have been struggling with for a while.
I have a Cocoa library which acts as a wrapper for a C++ library. C++ library is tested using a set of BOOST unit tests. The tests run normally under both debug and release modes.
In order to test the Cocoa wrapper I am using otest. Here is the strange part, the te...
If I declare a string constant like so:
You should create a header file like
// Constants.h
extern NSString * const MyFirstConstant;
extern NSString * const MySecondConstant;
//etc.
You can include this file in each file that uses the constants or in the pre-compiled header for the project.
You define these constants in a .m file li...
My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server with the following errors:
*** Terminating app due to uncaught exception 'N...
I use this code to set my constants
// Constants.h
extern NSInteger const KNameIndex;
// Constants.m
NSInteger const KNameIndex = 0;
And in a switch statement within a file that imports the Constant.h file I have this:
switch (self.sectionFromParentTable) {
case KNameIndex:
self.types = self.facilityTypes;
break;
...
I get e...
I have a block of code which is similar to the following:
for (NSDictionary *tmp in aCollection) {
if ([[bar valueForKey:@"id"] isEqualToString:[tmp valueForKey:@"id"]])
{
break;
}
else
{
[aCollection addObject:bar];
}
}
Is this technically an exception in Objective-C 2.0? It appears you cannot mutat...
Pretty horrendous newbie question here.
I'm looking at the following apple example source code:
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFor...
Consider the following ObjC code example:
-(void) doStuffWithString: (String *) someParam {
// Do stuff with someParam
}
If this code were being executed in a multi-threaded app, would it be a good idea to retain/release someParam? Specifically, I'm thinking of scenarios in which the passed-in parameter is a singleton object shared...
Hi
I'm learning Objective-C and Cocoa (in fits and starts when time allows) so be gentle OK.
A example app has the following lines:
NSPoint down = [mouseEvent locationInWindow];
//...some other stuff
NSPoint p = [self convertPoint:down fromView:nil];
It then proceeds to use p for a drag and drop operation (using the pasteBoard). But...
Is it possible to dynamically define methods in Objective-C like we would in Ruby?
[:failure, :error, :success].each do |method|
define_method method do
self.state = method
end
end
...
This is my first web API project, so I hope the solution to this isn't blindingly obvious.
// Contstruct the http request
NSString *urlString = [NSString stringWithFormat:@"http://%@:%@@twitter.com/statuses/user_timeline/%@.xml?count=5", username, password, friend];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest...
I have a UIViewController that allows me to view and edit information of a class.
It is only allocated once but it's number of rows,sections and data is passed to it depending on the value the user selected.
For example. Here it is editing a name & type property (Header view of table is too big.. I did this so you will see the weirdne...