hi,
i want to use webDAv server to share files among systems and (iPod or iPhone)in my iphone project.to use it,i have to use individual webserver?
or is it a built in facility ? any one can help?
I need some mechanism reminiscent of Win32 reset events that I can check via functions having the same semantics with WaitForSingleObject() and WaitForMultipleObjects() (Only need the ..SingleObject() version for the moment) . But I am targeting multiple platforms so all I have is boost::threads (AFAIK) . I came up with the following class and wanted to ask about the potential problems and whether it is up to the task or not. Thanks in advance.
class reset_event
{
bool flag, auto_reset;
boost::condition_variable cond_var;
boost::mutex mx_flag;
public:
reset_event(bool _auto_reset = false) : flag(false), auto_reset(_auto_reset)
{
}
void wait()
{
boost::unique_lock<boost::mutex> LOCK(mx_flag);
if (flag)
return;
cond_var.wait(LOCK);
if (auto_reset)
flag = false;
}
bool wait(const boost::posix_time::time_duration& dur)
{
boost::unique_lock<boost::mutex> LOCK(mx_flag);
bool ret = cond_var.timed_wait(LOCK, dur) || flag;
if (auto_reset && ret)
flag = false;
return ret;
}
void set()
{
boost::lock_guard<boost::mutex> LOCK(mx_flag);
flag = true;
cond_var.notify_all();
}
void reset()
{
boost::lock_guard<boost::mutex> LOCK(mx_flag);
flag = false;
}
};
Example usage;
reset_event terminate_thread;
void fn_thread()
{
while(!terminate_thread.wait(boost::posix_time::milliseconds(10)))
{
std::cout << "working..." << std::endl;
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
}
std::cout << "thread terminated" << std::endl;
}
int main()
{
boost::thread worker(fn_thread);
boost::this_thread::sleep(boost::posix_time::seconds(1));
terminate_thread.set();
worker.join();
return 0;
}
EDIT
I have fixed the code according to Michael Burr's suggestions. My "very simple" tests indicate no problems.
class reset_event
{
bool flag, auto_reset;
boost::condition_variable cond_var;
boost::mutex mx_flag;
public:
explicit reset_event(bool _auto_reset = false) : flag(false), auto_reset(_auto_reset)
{
}
void wait()
{
boost::unique_lock<boost::mutex> LOCK(mx_flag);
if (flag)
{
if (auto_reset)
flag = false;
return;
}
do
{
cond_var.wait(LOCK);
} while(!flag);
if (auto_reset)
flag = false;
}
bool wait(const boost::posix_time::time_duration& dur)
{
boost::unique_lock<boost::mutex> LOCK(mx_flag);
if (flag)
{
if (auto_reset)
flag = false;
return true;
}
bool ret = cond_var.timed_wait(LOCK, dur);
if (ret && flag)
{
if (auto_reset)
flag = false;
return true;
}
return false;
}
void set()
{
boost::lock_guard<boost::mutex> LOCK(mx_flag);
flag = true;
cond_var.notify_all();
}
void reset()
{
boost::lock_guard<boost::mutex> LOCK(mx_flag);
flag = false;
}
};
I'm a newbie in iPhone Programming. I'm trying to send a message from one view controller to another. The idea is that viewControllerA takes information from the user and sends it to viewControllerB. viewControllerB is then supposed to display the information in a label.
viewControllerA.h
#import <UIKit/UIKit.h>
@interface viewControllerA : UIViewController
{
int num;
}
-(IBAction)do;
@end
viewControllerA.m
#import "viewControllerA.h"
#import "viewControllerB.h"
@implementation viewControllerA
- (IBAction)do {
//initializing int for example
num = 2;
viewControllerB *viewB = [[viewControllerB alloc] init];
[viewB display:num];
[viewB release];
//viewA is presented as a ModalViewController, so it dismisses itself to return to the
//original view, i know it is not efficient
[self dismissModalViewControllerAnimated:YES];
}
- (void)dealloc {
[super dealloc];
}
@end
viewControllerB.h
#import <UIKit/UIKit.h>
@interface viewControllerB : UIViewController
{
IBOutlet UILabel *label;
}
- (IBAction)openA;
- (void)display:(NSInteger)myNum;
@end
viewControllerB.m
#import "viewControllerB.h"
#import "viewControllerA.h"
@implementation viewControllerB
- (IBAction)openA {
//presents viewControllerA when a button is pressed
viewControllerA *viewA = [[viewControllerA alloc] init];
[self presentModalViewController:viewA animated:YES];
}
- (void)display:(NSInteger)myNum {
NSLog(@"YES");
[label setText:[NSString stringWithFormat:@"%d", myNum]];
}
@end
YES is logged successfully, but the label's text does not change. I have made sure that
all of my connections in Interface Builder are correct, in fact there are other (IBAction)
methods in my program that change the text of this very label, and all of those other methods work perfectly...
Any ideas, guys? You don't need to give me a full solution, any bits of information will help. Thanks.
how does one use code to do this:
produce 15 random numbers that are not in any order, and that only occur once
eg.
1 4, 2, 5, 3, 6, 8, 7, 9, 10, 13, 12, 15, 14, 11
rand() or arc4rand() can repeat some, which is not what im after.
Thanks
Today my app approved, but I got emails from users says it crash. I figured out that
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide];
Is the problem, Because users have firmware 3.1.x this API is not working and app crash.
So I have replace it with
if ([[[UIDevice currentDevice] systemVersion] floatValue]>=3.2)
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide];
else
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
My questions...
Is what I did the best solution?
Why XCODE did not warn me that SetStatusBarHidden withAnimation is not in 3.0 while I set my Traget OS firmware 3.0?
Do I have to check on every API to see if it is working with my Target OS?
Thank you
I would like to create a time counter in my app that shows the user how many minutes the app has been running the current session and total. How do I create such time counter and how do I save the value to the phone? I'm new to app developement.
Starter question: My "Hello World" attempt won't run, ("No compatible targets were found"), I think this is bacause I selected the latest version for my project (2.2), and the highest AVD version is 2.0.1. Does this make sense? Can I change my project version (haven't been able to find a way to do this), or do I have to start again? If the versions are not backwards compatible, what is the best version to use for the majority of Android devices out there?
Thanks
My iPhone app has the following problem: Freshly installed, when I read out my "Play Sound" preference with the following code:
defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"Play Sounds? %d", [defaults boolForKey:@"play_sounds_preference"]);
The setting always reads out as false, even though the default setting is set to true. Any ideas? Here is my Root.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>General Settings</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Sounds</string>
<key>Key</key>
<string>play_sounds_preference</string>
<key>DefaultValue</key>
<true/>
</dict>
</array>
</dict>
</plist>
When the user opens the Settings.app and navigates to my app's name, THEN the setting reads out as true, even if the user doesn't change anything.
Hello, I'm working on multiple applications for my school. I just need this last bit of code and I was wondering how I could implement a UIViewAutoresizingFlexibleHeight into the app for each textfield. What this does is it makes the textfield pop above the keyboard, rather than over lapping it. I have already implemented a UIScrollView, so if someone on here could be pretty descriptive, or post a link to a video, that would be well appreciated. I am new to coding. Thanks very much!!!!
i want to send request on Https so do i need to install the SSL certificate as the steps are given for apple push notification
please help me i am new and i have never worked on OpenSSL
Has anyone come across a strange behaviour with the Camera API when used on Sony-Ericsson X10 or Droid?
For example the following code doesn't work on those devices. As a result I'm getting a lot of negative feedback on the Market translating into many cancelled orders...
mParameters.set("rotation", orientation);
mParameters.set("jpeg-quality", img_quality);
mParameters.set("picture-size", "1024x768");
mCamera.setParameters(mParameters);
Could you suggest an alternative way of achieving the same? Thanks.
Has anyone come across a strange behaviour with the Camera API when used on Sony-Ericsson X10 or Droid?
For example the following code doesn't work on those devices. As a result I'm getting a lot of negative feedback on the Market translating into many cancelled orders...
mParameters.set("rotation", orientation);
mParameters.set("jpeg-quality", img_quality);
mParameters.set("picture-size", "1024x768");
mCamera.setParameters(mParameters);
Could you suggest an alternative way of achieving the same? Thanks.
I've got a couple of Core Data-generated class files that I'd like to add custom methods to. I don't need to add any instance variables. How can I do this?
I tried adding a category of methods:
// ContactMethods.h (my category on Core Data-generated "Contact" class)
#import "Contact.h"
@interface Contact (ContactMethods)
-(NSString*)displayName;
@end
...
// ContactMethods.m
#import "ContactMethods.h"
@implementation Contact (ContactMethods)
-(NSString*)displayName {
return @"Some Name"; // this is test code
}
@end
This doesn't work, though. I get a compiler message that "-NSManagedObject may not respond to 'displayName' " and sure enough, when I run the app, I don't get "Some Name" where I should be seeing it.
I've seen in applications a popup that prompts me what I do want to do with a text. I am prompted to choose from Send by SMS, Send by Email, Send by Bluetooth, Send by Fring etc.
How do I make such a popup, it seamed to be automatically built?
Also how do I tell what message to use?
And if needed how do I tell who the contact is? Maybe chooses the options based on the contact, (if has email, show email)
Hi,
I have to manage xml's and Strings in my app.
by efficenty and memory saving, is collection(ArrayList) will be much more 'expensive' then array of Strings?
another issue is: i could use the content as regular String, or XML.. is working with XML also makes it more 'expensive' ?
when i say i expensive i talk about taking system sources.
please tell me by any of your exprience if the diffrences are significant?
thanks,
ray.
Hi Guys, Do you know what could cause this as a return for a Facebook Canvas app. It works for most users of our site but some users, it generates this and i cant figure out what would cause this. The userID is returned as 0 and the Token seems to be missing something. there is no other way for the users to reach the site other than visiting the Facebook App page... Please let me know what i can do to prevent this from happening
UserID: 0
Token: 104743107829|b8bbc20eac6127d8a9a85451490a0663
Quesrty String:signed_request=W13Y8eiSHTyyqBnyJjll8WngPFeQqabhVBkJaHnXYb4.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTI5NDU5NjIwMywidXNlciI6eyJsb2NhbGUiOiJpdF9JVCIsImNvdW50cnkiOiJpdCJ9fQ
Hello all,
i am using an example from the iphone developer book from apress.
the problem is that this example only works on the simulator im trying to figure out how i can make it work on the device. This chapter isn't working at all. below is the sample code. data.plist is located in the resource folder.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:kFilename];
Below then checks to see if the file is located. this is skipped, so im guessing this does not find the file.
if ([[NSFileManager defaultManager]fileExistsAtPath:filePath]) {
NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];
BGDataSave = [array objectAtIndex:0];
NSLog(@"%@", BGDataSave);
price.text = [array objectAtIndex:1];
percent.text = [array objectAtIndex:2];
salepriceLabel.text = [array objectAtIndex:3];
origpriceLabel.text = [array objectAtIndex:4];
}
hi, i i want to activate scrolling vertically through programming for UITableview?is it possible ?In one Viewcontroller's view i have scrollview, on that i have two tableviews(instead of one,like two column)..how can i scroll vertically both at same time?any help please?
hi,
is there any code on how to implement the sms scheme in iPhone apps. in addition, implementing
this sms scheme will allow my apps interact with the sms apps ma like doing subscription of
advertisement or services ?
any help, i truly appreciated it.
Cheers
I have a ViewController that has its own NIB. I would like to embed that NIB inside of another master NIB. How can I accomplish this in Interface Builder and how do I reference it in code?
I need to set sounds for different players in my game. There are 10 players. And I have 10 sounds.
The players are loaded int his way
for( int i = 1; i <5; i++ )
{
[playerAnimation addFrameWithFilename: [NSString stringWithFormat:@"Player %02d gun draw_%02d.png", playerNumber, i]];
}
How can I set the sounds in this way by giving the filenames. And player1 shoots player1sound should play.
How can I do it using
[[SimpleAudioEngine sharedEngine] playEffect:@"player1.sound.wav"];
hi,i coded like
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(230.0f, 4.0f, 60.0f, 36.0f);
[btn setTitle:@"OK" forState:UIControlStateNormal];
[btn setTitle:@"OK" forState:UIControlStateSelected];
[btn addTarget:self action:@selector(onClickRename:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:btn];
return cell;
}
but if the user selects the button on particular row, i can change that image through onClickRename...but can i get inwhich row's image has been touched through
(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath)indexPath ?
I have a custom table cell. In it I have put (via the IB) an image view of a certain frame
In 'cellForRowAtIndexPath', under certain conditions, I would like to modify the frame of this UIImageView, so I write something like:
UIImageView *imgv = (UIImageView *)[cell viewWithTag:1];
CGRect r = CGRectMake(20.0, 20.0, 10.0, 10.0);
imgv.frame = r;
But nothing expected happens (The frame does move a little though not to where I want, but doesn't change its size at all);