objective-c

NSString no 'assign', 'retain', or 'copy' attribute is specified

I'm declaring an NSString property in a class and objective-c is complaining that: NSString no 'assign', 'retain', or 'copy' attribute is specified It then casually lets me know that "assign is used instead". Can someone explain to me the difference between assign, retain and copy in terms of normal C memory management functions? ...

How to define a BOOL constant?

I know how to do it for a float: #define kMyConstant 1.0f but how could I do that fora BOOL value? ...

Where do I have to declare static variables?

i.e. I want to bring this in my code: static BOOL MyConstantBool = YES; Must it be before or after @implementation? Are there rules where to place that? Can it also go into the header file? ...

iPhone Network Connection after kIOMessageSystemHasPoweredOn

I've built an app that runs in the background (jailbroken phone, Ver. 3.0/7A341) that checks my website every hour. When the device goes to sleep, I set a time to wake up if it stays asleep My app wakes up fine, then tries to make a network connection, but no luck. I've tried what iphone-3g-connection-enabling recommends (NSURLConnecti...

Handle empty structs in Objective-C (Coordinate in custom class)

I have a custom class that has as an instance variable of a coordinate: CLLocationCoordinate2D eventLocation; @property(nonatomic) CLLocationCoordinate2D eventLocation; I'm parsing an xml file that has an optional field that may or may not be there. If it is i set it like so: CLLocationCoordinate2D location; NSArray *coordinateArray ...

Is it good style to declare methods in .h when they're intended to be overwritten by subclass?

I have a class which is intended to be abstract. This means: When someone subclasses it, a few methods MUST be overwritten. But on the other hand, those methods are not intended to be called manually from anywhere except inside the abstract class (the superclass of the subclass). Must I declare these methods in .h anyways or can I just...

Escaping backslashes in method call stringByReplacingOccurrencesOfString Does not work in Objective C

This line of code does not produce the result I am expecting. NSString *tmpstoryTitle2 = [tmpstoryTitle stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; I am attempting to change a string like this: hello, "this" is my string. to hello, \"this\" is my string. With the code above. However, the output I get is: hell...

Can't understand iPhone view layout

I have an iphone app that I built based off a tutorial (for a different framework so I had to modify things a bit) that uses a TabBar and a NavigationBar on the same View that also contains a UITable populated from an SQLite db. I built it last night and when you select an item in the UITable it was redirecting to a view that displayed t...

How to remove bottom bar from NavigationView/TableView

I have an app that has a TableView, NavigationView and TabBar running together. There is a bar along the bottom of the screen above the TabBar that looks exactly like the NavigationBar at the top of the screen. I have no idea what it is or how to get rid of it. Here is what it looks like with what I want gone crossed out: This is the ...

Battery Level Will Not Update

Hello there, I am having a small problem. I am a beginner to iPhone programming so please forgive me if the answer is obvious. I have found the current charge and want it to continually update while my app is running. I tried this: - (void) viewWillAppear:(BOOL)animated { NSLog(@"viewWillAppear"); double level = [self batteryLevel]...

I am trying to learn Objective C but maybe my enviroment is wrong?

#import <stdio.h> #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { printf("Hello World!!\n"); return 0; } I have a MacAir running OS X 10.6.1 with XCode version 3.2.1. When I attempt to compile the lines above I get 3951 errors. Most of them seem to be NSObjCRunntime.h file where NSString is defined. ...

Copying a directory off a network drive using Objective-C/C

Hi All, I'm trying to figure out a way for this to work: NSString *searchCommand = [[NSString alloc] initWithFormat:@"cp -R /Volumes/Public/DirectoryToCopy* Desktop/"]; const char* system_call = [searchCommand UTF8String]; system(system_call); The system() method does not acknowledge the specific string I am passing in. If I ...

Objective C double Delegate protocol

Hi, I get the following error when compiling my app. warning: class 'ConfigureViewController' does not implement the 'MPMediaPickerControllerDelegate' protocol I know that it means I have to implement the delegate in the Controller. i.e @interface ConfigureViewController : UIViewController < MPMediaPickerControllerDelegate > However, ...

objective-C : @synthesize not working and basic operations not working :*(

I am unsure why this code will not work and what i want it to do is when i click a button(action: buttonclick) i want it to change the two text box's(MyTextLabel & MyTextLabel2) text increment the value "r" by one. here is the code: MainView.h #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @interface MainView : UIView { ...

How to custom draw window title bar in Objective-C?

I'd like to customize the way I draw the window title bar on OS X. Specifically, I'd like to do something like the Twitterrific app where there is a custom close button, no min/max buttons, and the window title text is right-justified. Unlike Twitterrific, I'm not looking to custom draw the entire window (though I'm not completely oppose...

Accessing an SQLite DB for two separate queries on iPhone App Initialization

I was successfully accessing my database to get a list of cities on the App launch. I tried running a second query against it right afterward to get the list of States but all that happens is that my app blows up with no usable error in the console (simply says "Program received signal: EXEC_BAD_ACCESS" and nothing more). Here is the c...

MPVideoPlayer add/remove buttons.

Hi everyone! Does anyone knows how to add/remove buttons from the MPVideoPlayer window? I put bellow an example form an app that does that. It is in App Store which means that it is allowed by Apple. Thank you in advance. UPDATE I think that the main way to do it is just by obtaining the UITabBarController of the MPVideoPlayer window...

how to sync audio in iphone sdk with NStimer?

I am running a countdown timer which updates time on a label.i want to play a tick sound every second.i have the sound file but it is not sync perfectly with time.how do i sync time with audio?also if i use uiimagepicker the sound stops how to manage this? if someone have tick sound like a clock has it would be great. ...

How to record video without user interaction in iphone using ObjC

Hi! I'm working on an app. In which I need to provide the functionality to capture the video using iphone 3gs without touching any buttons. I want to use the timer to start and stop video recording. Any one have any idea. how to do this using new iphone sdk. Thanks in advance ...

HTML entity encoding (convert '<' to '&lt;') on iPhone in objective-c

I'm developing an application for the iPhone that has inApp-mail sending capabilities. So far so good, but now I want to avoid html-injections as some parts of the mail are user-generated texts. Basically I search for something like this: // inits NSString *sourceString = [NSString stringWithString:@"Hello world! Grüße dich Welt <-- Th...