objective-c

Objective-C Class Prefixes

What's your preference with naming ObjC classes? I'm a little uncertain what would be the most reasonable approach on this so it would be nice to hear some other opinions. Apple recommends prefixing cocoa classes, because ObjC doesn't support namespaces. The Google ObjC styleguide (which i mostly aim for) does away with them, unless you...

How to build a Ruby extension with Objective-C using new exceptions (@throw…)?

I have build a Ruby extension in Objective-C. Now I want to use @throw/@catch etc. instead of macro based exception handling and self build error handling. I am using the GNU runtime shipped with the GCC. When I run my Ruby app with my extension it core dumps as soon as an exception occurs. The abort() comes from the GNU Objective-C r...

Problem in uploading of video to server in Iphone sdk

Hi guy's When I am uploading the video file to the server I sending the sample file name to it. I am bit confused how to upload the video file with different file names. Due to this I am getting the same video file every time. My code is: - (NSData *)generatePostDataForData:(NSData *)uploadData { // Generate the post header: NSString ...

Overriding internal UIViewController methods because an internal method is giving me bugs

What are the consequences of overriding internal UIViewController methods? [UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] is giving me some problems. It resizes my frame to values I do not desire sometimes. I do not even know where it picks off the new frame's values (it is close to the size of the superview to where I ...

white space on top of UITabBarController

I need to add a UITabBarController as subView. But I can't remove the white space on top. Does anybody know a solution? Thanks, Andreas ...

Sha256 in Objective-C for iPhone

Hi, when i use this code to create a sha256 of a string unsigned char hashedChars[32]; NSString *inputString; inputString = [NSString stringWithFormat:@"hello"]; NSData * inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; CC_SHA256(inputData.bytes, inputData.length, hashedChars); it returns the hash correctly, but i nee...

Convert ASCII characters to readable text

Hi! I've been struggling all day with trying to find classes that converts/decodes ASCII characters to readable text. I've found this method here at Stack Overflow, and it fixes many of the characters to readable text. But I'm still struggling with for example: &44; &46; &58; &39; ...and so forth. I'm receiving my data from a XML...

Do I declare all the instance variables in the .h file in ObjC?

I am new to ObjC. If I want to declare instance variables for private use of my class, do I do that in the .h file of my class inside the curly brackets? If I just declare a variable in the body of the .m file, will it result in a global variable? Thanks ...

In Objective-C, what is the best way to add NSIntegers together?

This code works, hide the search bar if less than ten items, but I don't like the casts to int. Is there a better way to do it? if( kScreenFull > ((int)[[self tableView] numberOfRowsInSection:kReal] + (int)[[self tableView] numberOfRowsInSection:kIncome]) ) [self.tableView setContentOffset:CGPointMake(0.0, 44.0) animated:NO]; ...

Adding/removing sections/rows with UISwitch similar to Wi-Fi Networks switch of the Iphone

Hi, I am trying to make 2 switches, one that will add a section with 3 rows and one that will add a row in a existing section. if (alertSwitch.on == YES) { alert = YES; [myTable beginUpdates]; [myTable insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; [myTable endUpdates]; [myTable...

Key-value coding for mutable collections & atomic accessors

My question, in brief: Is there any way to make mutable collection KVO accessors thread-safe with the same lock that the @synthesized methods are locked? Explanation: I have a controller class which contains a collection (NSMutableArray) of Post objects. These objects are downloaded from a website, and thus the collection changes from t...

How to check if the value in an NSDictionary exists in an array of dictionarys

The title is a bit confusing...I'll explain I have an NSMutableArray I am populating with NSMutableDictionary objects. What I am trying to do is before the dictionary object is added to the array, I need to check whether any of the dictionaries contain a value equal to an id that is already set. Example: Step 1: A button is clicked se...

TabBar Controllers iphone

Hey Guys, Can you please explain me how to add a tab bar controller to the UIViewController..I think I have problem doing this..please help me..this is what I did so far..I added tab bar controller from IB and created a IBOutlet and made connections from file's owner to the Tab bar controller I added..when I run the app it displays a wh...

Compiling on Windows and Mac with Autotool

I have a problem trying to use autotools for a simple contrived project, the task is simple, use Objective-C on Mac OSX, and C++ on Windows (mingw) - with some C glue in the middle. The project is structured like so (minus all the automatically generated files): ./aclocal.m4 ./configure ./configure.ac ./Makefile.am ...

create empty NSDate object

Is this ok? NSDate *myDate; Because I used something like this before: NSDate *myDate = [[NSDate alloc] init]; if (something) myDate = thisDate; else myDate = thatDate; [myFunction initWithDate:myDate]; I always got "Value stored to 'myDate' during its initialization is never read". If I do something like this if (some...

How to call a method when 'No Cellular Network Available'.

Hi all, I am implementing an API based application. As per the requirements I need to show an alert when "No Cellular Network Available". I go through the documentations didn't find any solution. Can guys please help me on this it is very urgent. Thank you, Monish. ...

Using Structs in Objective-C (for iOS): Premature Optimization?

I realize that what counts as premature optimization has a subjective component, but this is an empirical or best-practices question. When programming for iOS, should I prefer using struct and typedefs where the object has no "behavior" (methods, basically)? My feeling is that the struct syntax is a bit strange for a non-C person, but t...

UIAlertView - Having some issues with getting a method to display a simple NSLog message

I am playing around with UIAlertView and am trying to simply display an NSLog message if the user clicks on the cancel button. I just can't figure out why absolutely nothing is happening. Here's the code that I have in place: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexpath { NSUInteger ro...

Ints to Bytes: Endianess a Concern?

Do I have to worry about endianness in this case (integers MUST be 0-127): int a = 120; int b = 100; int c = 50; char theBytes[] = {a, b, c}; I think that, since each integer sits in its own byte, I don't have to worry about Endianess in passing the byte array between systems. This has also worked out empirically. Am I...

Working with UITextField

Hi, I am using UITextField to get login and password from a user and then i use web service to send XML file using SOAP to a site and after successful authentication the user logs in and another screen is displayed. The next screen has a button to redirect to the previous screen where user can again enter login and password. I enter lo...